projection not working with find query

前端 未结 2 617
梦毁少年i
梦毁少年i 2020-11-30 15:22

Hello I\'d like to exclude some fields by query,. Im using nodejs

public async getDoc() {
        return new Promise((resolve, reject) => {
            t         


        
2条回答
  •  长情又很酷
    2020-11-30 15:46

    Use fields object as 2nd parameter in find method with all fields in that object which you want to get exluding password.

    Do it like this:

    find({email: "value3"}, {fields: {all_other_fields...: 1}})
    

    You can also try {fields: {password: 0}} as well but I haven't tried it myself that's why I'm not sure that it'll work.

提交回复
热议问题