How can you populate something that is not in the schema? Mongoose is throwing the error 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.
I tried adding strictPopulate: false
to the Schema and the query. Both didn't work.
It seems this works for me
document.populate([{ path: keyString, strictPopulate: false }]);
Suppose you have a product orderItem
inside orderList
. You can't populate producy when reading orderList
, instead you can use:
.populate({ path: "orderItems", populate: "product" });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.