投影不适用于查找查询 [英] projection not working with find query
本文介绍了投影不适用于查找查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想按查询排除某些字段.我正在使用nodejs
Hello I'd like to exclude some fields by query,. Im using nodejs
public async getDoc() {
return new Promise((resolve, reject) => {
this.database.collection('users').find({email: "value3"}, {password: 0}).toArray((err, result) => {
if(err) {
reject(err)
}
resolve(result);
});
})
}
但是在结果集中,我一直在获取密码字段.
but in the result set I keep getting password field..
推荐答案
投影不适用于新的nodejs mongodb驱动程序...而是必须使用
Projection doesn't work with the new nodejs mongodb driver... Instead you will have to use .project()
cursor method here
this.database.collection('users')
.find({ "email": "value3" })
.project({ "password": 0 })
.toArray();
这篇关于投影不适用于查找查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文