How to get array of json objects rather than mongoose documents

前端 未结 2 1045
暖寄归人
暖寄归人 2021-02-01 17:46

When I do find operation like the follows:

Collection.find({name: \'Erik\'}, function (err, docs) {
   // do momething
});

\'docs\' variable is

2条回答
  •  名媛妹妹
    2021-02-01 18:32

    .exec(function(err, docs){
        docs= docs.map(o => o.toObject());
    

    This will include virtuals and getters

提交回复
热议问题