Mongodb 报 because it is not in your schema. Set the `strictPopulate` option to f

58 阅读1分钟

背景

今天使用mongodb的populate 方法做外键查询、抛出了路径不对的错误提示

解决方案

this.model.find().populate({ path: 'pageId',  model: 'page', })

其中pageId是我当前集合的外键Keymodel为外键集合名

参考文献

stackoverflow.com/questions/4…