0

I'm building an app with NextJS, using AWS Amplify with DynamoDB + GraphQL, and was wonder what would be the best approach to making updates to my database if I'm giving the user the ability to constantly make changes on the front end.

For example, if I have a draggable todo list and user is able to drag around a task, this will affect the position of the task, thus causing updates to the database.

How can I approach this so these small incremental changes, won't be constantly updating my database?

hellomello
  • 8,219
  • 39
  • 151
  • 297
  • 2
    Option 1 > Provide your users with something like a "done for now" button. Store changes in the local storage until they press it. (Better) Option 2 > Sync the list periodically instead of doing it on change (recommended -- [debounce](https://lodash.com/docs/4.17.15#debounce) your handler instead, and `flush` it [before unload](https://stackoverflow.com/q/7317273/11613622)). Somewhat like how Microsoft ToDo, Sticky Notes, etc. work, Gmail too. A user adds/modifies some content. It locally will show the updated content to them. After some time the updated content will be synced with their db. – brc-dd Oct 14 '21 at 07:53
  • 1
    @brc-dd ah. Maybe the debounce was what I was looking for! – hellomello Oct 14 '21 at 16:00

0 Answers0