流星 $and 与 $or

Meteor $and with $or

我正在尝试在 Meteor 中为我的 mongo 查询执行 $and 然后 $or 我有以下内容,但它似乎不起作用

希望查询匹配 organizationId 键在变量 user.organizationId 中具有值且类型键为 'converntional' 或 'transition'

的文档
{
    organizationId: user.organizationId,  
    $and:[
       { $or:[
           {type: 'conventional'},
           {type: 'transition'}
       ]}
   ]
}; 

我不能使用 $not,因为我很确定 Meteor 不支持它。现在我使用的包不支持它。

以下查询描述了您所追求的,因为它使用了 $in operator to match documents where the type key is either 'converntional' or 'transition'. The $and operator is implicitly provided when specifying a comma separated list of expressions. Using an explicit AND with the $and 运算符,仅当必须在多个表达式中指定相同的字段或运算符时才需要。

Would like the query to match documents where organizationId key has value in the variable user.organizationId AND where the type key is either 'converntional' or 'transition'

{
    organizationId: user.organizationId, 
    type: { 
        $in : ['conventional', 'transition'] 
    }
}