I've connected my SailsJs app to a Mongodb database. I'm working on an analytic application. These are the major models in my application:
User
Project
Report
Event
A user can have many projects, a project can have many reports and a report can have many events. I have created these relations using collection
and model
properties of my models attributes. My problem is why is it so hard to find events of specific user? I wish I could do this:
User.
find({id: id}).
populate('projects').
populate('reports').
populate('events').
then(function (eventsOfMyUser) {
});
but since only projects
is an attribute of my User
model only the first populate works. Shouldn't be an easier way to find a deep model rather than writing nasty and confusing async loops in my controller or model code?