How can I assign an array to a variable. I am able to return the documents that I want but not able to specifically get all the elements in the array inside a particular field. This field is called 'likes.'
My query to filter documents I want:
Posts.find({}, {owner: Meteor.user()})
I would like to retrieve all the elements inside an array field called 'likes' from the Posts collection. (Each element in the 'likes' field is an object ID)
I tried with various operators such as $all and $in of the 'likes' field and tested within console.log, but I cant manage to get the Ids. According to the mongo docs, I need to specify an element within the operator but I don't want that. I simply want anything that is inside.
var likers = Posts.find({}, {owner: Meteor.user()}, {likes: {$in: [] }})
Basically, Im trying to retrieve all the elements from the 'likes' field so I can make another query to return results.
I am running meteor 0.9+