简体   繁体   中英

Meteor Collection.find() everything except a value

I want meteor to return all Items that have not been marked as inactive. The inactive flag is just set if the item is marked inactive.

Marking an Item as inactive:

Template.displayedItems.events({
    'change [type=checkbox]': function(event) {
    var checked = $(event.target).is(':checked');
    Items.update(this._id, {$set: {inactive: checked}});
}

How do I have to query to get all items that are not inactive?

What about:

Items.find({inactive : false})

Should do the trick. Check the doc for more!

如果要获取未设置inactive字段值的文档,则可以使用$ exists

Items.find({inactive : { $exists: false }})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM