简体   繁体   English

流星Collection.find()除值外的所有内容

[英]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 }})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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