![](/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.