Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.getCollection('collection-name').aggregate([
- {
- $match: { _id: ObjectId("60c08f97f4738c0018701eb9") }
- // other conditions ...
- },
- {
- $set: {
- // MongoDB will creates this field if there is not
- fieldName: {
- // this operators will generate random numbers from 0 to 20 for this field
- $floor: {
- $multiply: [ { $rand: {} }, 20 ]
- }
- }
- }
- },
- {
- $merge: {
- into: 'contractors',
- on: '_id',
- whenMatched: 'merge',
- }
- }
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement