[英]How to turn off strictpopulate in mongoose?
您如何填充模式中不存在的内容? Mongoose 抛出错误Cannot populate path 'example' because it is not in your schema. Set the 'strictPopulate' option to false to override.
Cannot populate path 'example' because it is not in your schema. Set the 'strictPopulate' option to false to override.
我尝试将strictPopulate: false
添加到架构和查询中。 两者都不起作用。
这似乎对我有用
document.populate([{ path: keyString, strictPopulate: false }]);
假设您在orderList
中有一个产品orderItem
。 阅读orderList
时不能填充产品,而是可以使用:
.populate({ path: "orderItems", populate: "product" });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.