本文介绍了猫鼬__v属性-隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
猫鼬在Schema的版本中添加了一个'__v'属性-是否可以全局禁用此属性或在所有查询中全局隐藏它?
Mongoose adds a '__v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries?
推荐答案
您可以通过将versionKey
选项设置为false
来禁用架构定义中的"__v"属性.例如:
You can disable the "__v" attribute in your Schema definitions by setting the versionKey
option to false
. For example:
var widgetSchema = new Schema({ ... attributes ... }, { versionKey: false });
我不认为您可以全局禁用它们,但只能按照Schema进行操作.您可以在此处阅读有关Schema的选项的更多信息.您可能还会发现架构设置方法很有帮助.
I don't think you can globally disable them, but can only do it per Schema. You can read more about Schema's options here. You might also find the Schema set method helpful.
这篇关于猫鼬__v属性-隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!