I'm having two models of let's say A and B. It's an 1:n relation, where one A owns one B, and B can be owned my multiple As.
Now, if possible, B shouldn't have to know about all the As it's referenced in, so I'm only associating on the A side.
Now I want to search for all As that own a B with a certain criteria. I've basically tried this:
A.find()
.populate('B', {
where: {
someAttr: 1
}
})
Looking at the documentation I find this pretty similar to the example there.
Now I'm getting the following error:
Could not populate
B
because of ambiguous usage. This is a singular ("model") association, which means it never refers to more than one associated record. So passing in subcriteria (i.e. as the second argument to.populate()
) is not supported for this association, since it generally wouldn't make any sense. But that's the trouble-- it looks like some sort of a subcriteria (or something) was provided!
Can I somehow make this query work without giving B a reference back on A? I feel like this is unnecessary bloating of the models.
I'm using Sails 1.0.1 right now.