什么是"__v"?猫鼬中的字段 [英] What is the "__v" field in Mongoose

查看:246
本文介绍了什么是"__v"?猫鼬中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Mongoose版本3与MongoDB版本2.2一起使用.我注意到MongoDB文档中已经开始出现__v字段.与版本控制有关吗?如何使用?

I'm using Mongoose version 3 with MongoDB version 2.2. I've noticed a __v field has started appearing in my MongoDB documents. Is it something to do with versioning? How is it used?

推荐答案

此处:

versionKey是首次创建时在每个文档上设置的属性 由猫鼬.此键值包含 文档.此文档属性的名称是可配置的.这 默认值为__v.

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' })

这篇关于什么是"__v"?猫鼬中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆