Thursday, 18 June 2020

Help with mongoose deep populations

hi all, hopefully someone can help me here.​I have three documents that I'm going to be needed aggregated. I should also mention that this is going to take place after the top level document has been created.​I have a Main schema which has an array of Users. Within that Users document, I have an array of Comments ObjectIds. I need to create the Main object, and populate the users, then populate the comments. This is what i have curently.``` main.save();const populated = Main.populate(main, { path: 'users', populate: { "comments", } });```This will populate the users within Main, but the array of ObjectIds will remain on the Users object instead of the comments document. I feel like I'm slightly off here with this.

Submitted June 18, 2020 at 06:00PM by TaGeuelePutain

No comments:

Post a Comment