algorithm - The offset a number of records after insert(MongoDB) -


i faced small problem. should offset of records after insert. small example :

notes: table has next structure. {id : long, priority : int}

current state of table:

{id: 103, name:"task #1", description:"text", priority: 1} {id: 641, name:"task #2", description:"text", priority: 2} {id: 2225, name:"task #3", description:"text", priority: 3} {id: 7741, name:"task #4", description:"text", priority: 4} 

step#1 insert new document, {id: 8888, name:"task #5", description:"text", priority: 2}.

state after insert operation:(priority unique field , should offset previous documents)

{id: 103, name:"task #1", description:"text", priority: 1} {id: 8888, name:"task #5", description:"text", priority: 2} {id: 641, name:"task #2", description:"text", priority: 3} {id: 2225, name:"task #3", description:"text", priority: 4} {id: 7741, name:"task #4", description:"text", priority: 5} 

the method found mass update.do know method\mechanism implement operation?(i can change table structure or perform operation record on code)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -