Meteor JS : How to make a query that finds all contained values in an array using the MongoDB ?

MongoDB operator : $in

Syntax : Collection.find({attribute:{$in:array}});

Example :

Meteor.publish('ArtistsEvent',function(id){
    var event = Events.findOne({_id:id});
    if ( event.attractions ){
        var att = [];
        event.attractions.forEach(function(entry) {
            if (entry.artist){
                att.push(entry.artist);
            }
        });
    }
    return Meteor.users.find({_id:{$in:att}});
});

1 Comment

  1. I truly enjoy looking at on this web site , it contains superb blog posts. Heavierthanair flying machines are impossible. by Lord Kelvin. efecbcdkgfacfced

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s