猫鼬 __v 属性 - 隐藏? [英] Mongoose __v property - hide?

查看:20
本文介绍了猫鼬 __v 属性 - 隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mongoose 在 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 的更多信息.您可能还会发现架构设置方法很有帮助.

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 属性 - 隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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