I am trying to create my own to-do list using Javascript, Python and MongoDB. I was fixated on how to process a task order.
My current idea is to have an order field in each task document, and when the order changes on the client, I would take a list of tasks from db and reorder each task separately / sequentially. This seems inconvenient because large to-do lists will mean a large number of requests. Is there a way to update a field in multiple documents sequentially?
I am also looking for tips on whether this is the best way to do this. I want to be able to maintain a to-do list, but maybe I will go this route wrong.
{ "_id" : ObjectId("50a658f2cace55034c68ce95"), "order" : 1, "title" : "task1", "complete" : 0 } { "_id" : ObjectId("50a658fecace55034c68ce96"), "order" : 2, "title" : "task2", "complete" : 1 } { "_id" : ObjectId("50a65907cace55034c68ce97"), "order" : 3, "title" : "task3", "complete" : 1 } { "_id" : ObjectId("50a65911cace55034c68ce98"), "order" : 4, "title" : "task4", "complete" : 0 } { "_id" : ObjectId("50a65919cace55034c68ce99"), "order" : 5, "title" : "task5", "complete" : 0 }
user830186
source share