如何关闭猫鼬中的 strictpopulate?

ill*_*ter 2 javascript mongoose mongodb node.js

如何填充架构中没有的内容?Mongoose 抛出错误Cannot populate path 'example' because it is not in your schema. Set the 'strictPopulate' option to false to override.

我尝试添加strictPopulate: false到架构和查询中。两者都不起作用。

小智 5

看来这对我有用

document.populate([{ path: keyString, strictPopulate: false }]);
Run Code Online (Sandbox Code Playgroud)