node.js - Mongoose 中的 "__v"字段是什么

我正在使用 Mongoose 版本 3 和 MongoDB 版本 2.2。我注意到 __v 字段已开始出现在我的 MongoDB 文档中。它与版本控制有关吗?它是如何使用的?

最佳答案

来自 here :

The versionKey is a property set on each document when first created by Mongoose. This keys value contains the internal revision of the document. The name of this document property is configurable. The default is __v.

If this conflicts with your application you can configure as such:

new Schema({..}, { versionKey: '_somethingElse' })

关于node.js - Mongoose 中的 "__v"字段是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12495891/

相关文章:

java - 为什么 MongoDB Java 驱动程序在条件中使用随机数生成器?

javascript - cursor.forEach() 中的 "continue"

mongodb - 如何在 MongoDB 中将集合从一个数据库复制到另一个数据库

sql - MongoDB 在 v4 之前不符合 ACID 的真正含义是什么?

node.js - Mongoose:findOneAndUpdate 不返回更新的文档

node.js - 如何在 Node.js Web 应用程序中管理 MongoDB 连接?

mongodb - 如何在 mongo 控制台中通过 ObjectId 搜索对象?

mongodb - 如何在 Node.js 中使用 Mongoose 进行分页?

node.js - mongodb/mongoose findMany - 查找 ID 列在数组中的

mongodb - 如何在 MongoDB shell 中打印出 20 多个项目(文档)?