I have a model (A) in waterline with the 'collection' type (which contains IDs of other model (B) instances). I would then like to find all records of A whose collection contains a specific ID of B.
First I tried
A.find({where: {collection_of_B: {contains: B_ID}}})
which didn't return what I wanted. Then I found a stackoverflow post saying that this type of query was not currently possible with waterline and that a native query to mongodb should be used instead. This brings me to my question as I first thought that a collection would be translated to an array in mongo but that doesn't seem to be the case.
I tried this query (based on mongodb documentation)
A.native(function(err, collection) {
var cursor = collection.find({collection_of_B: B_ID});
....
But that didn't return anything either and when I instead tested to find documents based on a field that was just a string in my waterline model it worked as expected but I also couldn't see the collection type on the mongo document when I printed it to terminal.
So, how is a waterline collection attribute type stored in mongodb? And how do I make a query to find records with a specific value in the collection?