简体   繁体   English

是Meteor应用程序中的$ or Mongo的一部分吗?

[英]Is $or part of Mongo in a Meteor App?

I am assuming this is a mongo syntax thing. 我假设这是mongo语法。 It's from a meteor app: 来自流星应用:

const { selectedSectionId } = this.state;

                const assignmentsSelector = {
                    formativeId: this.props.formative._id,
                    $or: [{ public: true }],
                 };

                 if (selectedSectionId && selectedSectionId !== 'all') {
                    assignmentsSelector.$or.push({ sectionId: selectedSectionId });
                 }

In the above what's the $or ? 在上面的$or什么?

As defined in the MongoDB documentation: 根据MongoDB文档中的定义:

The $or operator performs a logical OR operation on an array of two or more expressions and selects the documents that satisfy at least one of the expressions. $ or运算符对两个或多个表达式的数组执行逻辑或运算,并选择满足至少一个表达式的文档。

It appears that your $or array within assignmentsSelector only contains an expression to see if any document has a public property that is true. 您的$ or数组似乎在assignmentsSelector中仅包含一个表达式,以查看是否有任何文档具有正确的公共属性。 The conditional underneath the definition of assignmentsSelector provides the opportunity for you to add another expression to that array so that the $or operator will kick in. assignmentsSelector定义下的条件条件为您提供了向该数组添加另一个表达式的机会,以便$ or运算符可以加入。

For more on how $or behaves, visit the documentation here . 有关$ or行为的更多信息,请访问此处的文档。

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

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