I am trying to make a delivery app and I need the "dealer" as they take an order to go to the end of the queue and the next one to take its place, etc.
Example: 1,2,3,4,5,6,7,8,9,10, the "dealer" 1 would go to 10 when taking an order and would have 2,3,4,5,6,7,8, 9,10,1 and so on.
So my question is: is there an efficient way to do this in Node with Mongoose? How would you do it? Thank you!
The only thing I can think of is to get the last order number and add 1 to it and then update the previous records with minus 1 ...
Another thing I can think of is to "sort" the oldest record (above) and delete it and then create a new record that would go to the bottom. That way I would make the queue work, I don't know.
question from:
https://stackoverflow.com/questions/65907404/queue-in-mongoose-and-node 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…