These are chat archives for Automattic/mongoose

24th
Nov 2018
Smackzter
@Smackzter
Nov 24 2018 00:13
Is there a way to find a subdocument by it's global ObjectId? If my Submodel Bar is embedded in an array of Bar on my Model Foo, is there a reliable way to do something ala Foo.findById(idformybardocument)?
With the premise that I don't know which Foo document contains my Bar
I have heard chatter about the aggregate functionality in Mongoose but never heard how to use it
Really stuck on this so help is greatly appreciated! <3
Also if the functionality I describe isn't possible without iterating every Foo, I'd settle for a reliable way to find Bar in an array of Bar on the Foo model.