Sunday 30 December 2018

Populating multiple layered models in MongoDB.

Hello,I'm having a problem with populating my MongoDB models.I already did one populating before this and it worked:.populate({ path: "comments", populate: { path: "commenter" } }) I tried doing this but it didn't work. How do I make this work?.populate({ path: "posts", populate: { path: "comments", populate: { path: "commenter" } }, populate: { path: "poster" } }) I basically have a User model that I find and I need to populate a field "posts" and "poster" in it, then I need to populate "comments" and "poster" in posts and then populate "commenter" in "comments"Does anyone know how to do this or a better way of populating models in MongoDB.

Submitted December 30, 2018 at 04:47PM by AmirSaran

No comments:

Post a Comment