javascript - Meteor collection filtering collection -


i have collection of 4 objects

[obj1, obj2, obj3, obj4] 

what way implement filter logic single flag when it's true, get

[obj1, obj2 obj3] 

and when it's false, get

[obj1, obj2, obj4] 

i'm thinking quite while , not able came solution 1 flag.


my flat student = true/false

here have tried

obj1 = {}; obj2 = {}; obj3 = {student: true}; obj4 = {student: false};  var studentflag; // set flag  collection.find({$or: [{student: {$exists: false}}, {student: studentflag}]}).fetch(); 

i expecting when studentflag true, query gives me obj1, obj2, obj3 , when it's false, obj1, obj2, obj4. query ends invalid selector

if flag either true or unset, can do:

collection.find({student: true}).fetch() 

or

collection.find({student: {$ne: true}}).fetch() // not true or unitialized 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -