var _id;
Post.insertOne({ a: 1 })
.then((result) => {
_id = result.insertedId;
return Post.find({ _id }).limit(1).next();
})
.then((result) => {
console.log(result);
return Post.findOneAndUpdate({ _id }, { $set: { b: 1 } }, { returnOriginal: false });
})
.then((result) => {
console.log(result);
return Post.findOneAndReplace({ _id }, { $set: { c: 1 } }, { returnOriginal: false });
})
.then((result) => {
console.log(result);
});
{ _id: 561d483c5e0f7e684c1f88d8, a: 1 }
{ value: { _id: 561d483c5e0f7e684c1f88d8, a: 1, b: 1 }, lastErrorObject: { updatedExisting: true, n: 1 }, ok: 1 }
{ value: { _id: 561d483c5e0f7e684c1f88d8, a: 1, b: 1, c: 1 }, lastErrorObject: { updatedExisting: true, n: 1 }, ok: 1 }
{ _id: 561d483c5e0f7e684c1f88d8, c: 1 }
--
You received this message because you are subscribed to the Google Groups "node-mongodb-native" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-mongodb-na...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Name | Type | Description |
---|---|---|
value |
object | Document returned from findAndModify command. |
lastErrorObject |
object | The raw lastErrorObject returned from the command. |
ok |
Number | Is 1 if the command executed correctly. |
To unsubscribe from this group and stop receiving emails from it, send an email to node-mongodb-native+unsub...@googlegroups.com.