user2344293
user2344293

Reputation: 173

Collection Filtering using Field in Mongo DB in Meteor?

I need to know about filters using mongo collections using collection fields in meteor.

In my collection there are 3 fields in total:

  1. Name
  2. Staff Yes/No
  3. Qualification B.tech/M.tech

How to Filter using Staff either selects 'Yes' or 'No' and 'All'?

If selects 'Yes' then only get results from collection in staff field using 'Yes'?

I didn't get any idea about this.So please suggest me what do for this?

Code :

getStaffYesResult: function getStaffYesResult(callback){    
    console.log('********* getStaffYesResult ************** ');

    var filterResult = auth_user.findOne({is_staff:1});//Here get all records is staff true indicates 1 in collection.

    console.log('filterResult Length : ' + filterResult.length);
}

Upvotes: 1

Views: 1435

Answers (1)

Alveoli
Alveoli

Reputation: 1202

You'll want to use collection.find.

See the official documentation at: http://docs.meteor.com/#/full/find

An example would be:

var find = Person.find({staff: true});

Upvotes: 1

Related Questions