当使用Mongoose并查询数据库时,默认选择所有字段,我必须明确告诉Mongoose我不想选择哪些字段,例如,如果我不想要字段 user我应该做:
var schema = new Schema(
{
insertedAt: {type: String},
tags: {type: String},
user: {type:Object, select:false},
connectedIds: {type:Array}
}
Run Code Online (Sandbox Code Playgroud)
问题是,如果没有API开发人员(我)知道它,可能会将字段添加到数据库中.
有可能告诉Mongoose 只选择明确设置的字段吗?
mongoose ×1