簡體   English   中英

如何關閉 mongoose 中的嚴格填充?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM