Mongoose populate returning empty array

后端 未结 4 967
我寻月下人不归
我寻月下人不归 2021-01-28 04:25

I am trying to use mongoose populate function but in response I am getting empty array, I have seen multiple posts regarding this

var MerchantSchema = new mongo         


        
4条回答
  •  后悔当初
    2021-01-28 04:49

    Make sure that packages array in Merchant schema contains ObjectIds of type string, (not number). You can ensure this with something like:

    merchant.packages.map(r => { r._id = r._id + ''; });
    

提交回复
热议问题