简体   繁体   中英

Is $or part of Mongo in a Meteor App?

I am assuming this is a mongo syntax thing. 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 ?

As defined in the MongoDB documentation:

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.

It appears that your $or array within assignmentsSelector only contains an expression to see if any document has a public property that is true. 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.

For more on how $or behaves, visit the documentation here .

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