Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

node.js - Queue in Mongoose and Node

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...