![](/img/trans.png)
[英]How to change the value of a field in a stream of tweets before storing in MongoDB using NodeJS
[英]MongoDB Change Stream: Can I get value before update/delete?
更新操作中的更改流事件仅返回更改后的文档,与oplog相同。 我可以在更新之前获取文档(或一些更新的值)吗?
MySQL基于行的binlog可以使用完整的 binlog_row_image做到这一点。
不,从更改流中,更新事件如下所示:
{
_id: { < Resume Token > },
operationType: 'update',
clusterTime: <Timestamp>,
ns: {
db: 'engineering',
coll: 'users'
},
documentKey: {
_id: ObjectId("58a4eb4a30c75625e00d2820")
},
updateDescription: {
updatedFields: {
email: 'alice@10gen.com'
},
removedFields: ['phoneNumber']
}
}
仅存在新值,这与MySQL之前和之后都不同。
在findAndModify命令中,您可以选择指定(new:true / false)是返回新版本(true)还是文档的原始版本(false,这是默认值)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.