nickzuck_007

mongo db increment

Apr 11th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.26 KB | None | 0 0
  1. db.system.js.save(
  2. { "_id": "increment", "value": function getNextSequenceValue(sequenceName){ var sequenceDocument = db.vaibhav.findAndModify({ query:{_id: sequenceName }, update: {$inc:{sequence_value:1}}, new:true }); return sequenceDocument.sequence_value; } });
Advertisement
Add Comment
Please, Sign In to add comment