Hy there
Before moving on to the hack / crop method, I wanted to know if there is a built-in query method for checking empty / non-empty relationships from many to many, since I have not been successful in google or doc.
If I take an example in a document, imagine that I want to get the user only if he has Pet or Retrive Pet without an owner through a request.
// A user may have many pets var User = Waterline.Collection.extend({ identity: 'user', connection: 'local-postgresql', attributes: { firstName: 'string', lastName: 'string', // Add a reference to Pet pets: { collection: 'pet', via: 'owners', dominant: true } } }); // A pet may have many owners var Pet = Waterline.Collection.extend({ identity: 'pet', connection: 'local-postgresql', attributes: { breed: 'string', type: 'string', name: 'string', // Add a reference to User owners: { collection: 'user', via: 'pets' } } });
Ps I know how to filter the results after the query is completed, and not what I ask :)
source share