Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以从查询结果中排除一个字段,声明如下:
字段:{类型:'字符串',选择:假}
但是可以用 _id 和 __v 字段来做到这一点吗?我试过
_id:{选择:假}
但它似乎不起作用
只要您还在type架构定义中包含该字段,您就可以执行此操作:
type
_id: {type: mongoose.Schema.ObjectId, select: false}, __v: {type: Number, select: false},
但是,除非您__v在. 因此,请确保您知道自己在做什么。savefind
__v
save
find