Mongoose/Mongodb: Exclude fields from populated query data

后端 未结 4 626
灰色年华
灰色年华 2020-12-31 03:31

I use the following mongoose query in a MEAN-environment to find and output a particular author and his corresponding books.

Author
.findOne({personcode: co         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 04:01

    Thanks JohnnyHK, and for object parameter this works:

    Entity.populate({
        path: 'bookids',
    
        // some other properties
        match: {
            active: true
        },
        // some other properties
    
        select: '-_id -__v' // <-- this is the way
    }).then(...) // etc
    

提交回复
热议问题