更新,所以不确定限制返回字段是否会节省成本,但我会选择最小的一个。非常感谢你的回答。我将在这里为其他人列出比较结果作为注释。感谢@Anthony Winzlet和@Florian Schlag感谢您抽出时间:)
一。方法:
updateOne
返回字段:
{"n":1,"nModified":1,"opTime":{"ts":"xxxxxxxxxxxxxxxxxxx","t":14},"electionId":"xxxxxxxxxxxxxxxxxxx","ok":1,"operationTime":"xxxxxxxxxxxxxxxxxxx","$clusterTime":{"clusterTime":"xxxxxxxxxxxxxxxxxxx","signature":{"hash":"xxxxxxxxxxxxxxxxxxx","keyId":"xxxxxxxxxxxxxxxxxxx"}}}
字节大小:286
2。方法:添加
projection
在里面
findOneAndUpdate
并且只返回
_id
返回字段:
{"_id":"xxxxxxxxxxxxxxxxxxxxxxxx"}
字节大小:34