[DOCS-12543]  $and operator accepts one expression Created: 12/Mar/19  Updated: 30/Oct/23  Resolved: 27/Mar/19

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: 3.6.6
Fix Version/s: Server_Docs_20231030

Type: Typo Priority: Major - P3
Reporter: Betty Leung Assignee: Ravind Kumar (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 4 years, 46 weeks ago
Story Points: 0.1

 Description   

Description

From the mongoDB documentation:

{{}}

$and performs a logical AND operation on an array of two or more expressions

 

However, I am able to run a mongo query with just one expression.

For example in Studio 3T I run:

db.getCollection("mycollection").find({ 

"$and": [

{ "memId":"07e3c5560dc125689eb75bfd120ceb91"  }

]

})

 

Is this a typo in the documentation or an incorrect implementation of mongoDB?

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Betty Leung [ 27/Mar/19 ]

Thank you for the documentation updates and info @Ravind Kumar.  I am able to run the $or operator with only one operation as well. However, the mongo documentation states:

The $or operator performs a logical OR operation on an array of two or more<expressions>

https://docs.mongodb.com/manual/reference/operator/query/or/#op._S_or

 

Is this also a documentation typo?{{}}

Comment by Ravind Kumar (Inactive) [ 27/Mar/19 ]

Thanks for filing this betty.leung@interpreta.com. I've clarified the description to one or more arguments. As you noted, $and is perfectly happy with a single argument. I've backported the changes as well.

If you run into any further issues with the MongoDB Documentation, please feel free to open another ticket.

Comment by Githook User [ 27/Mar/19 ]

Author:

{'email': 'ravind.kumar@mongodb.com', 'name': 'rk-mongo'}

Message: Multiple small fixups:

DOCSP-4943: $cond requires all arguments
DOCS-12556: Deprecate GridFS contentType, aliases, MD5
DOCS-12543: query $and accepts one expression
DOCSP-4791: Certain background operations can block setFeatureCompatibilityVersion
Branch: v3.4
https://github.com/mongodb/docs/commit/1216a876af0bcdecd370707ed551d08846958023

Comment by Githook User [ 27/Mar/19 ]

Author:

{'email': 'ravind.kumar@mongodb.com', 'name': 'rk-mongo'}

Message: Multiple small fixups:

DOCS-12567: Removing duplicate line
DOCSP-4943: $cond requires all arguments
DOCS-12556: Deprecate GridFS contentType, aliases, MD5
DOCS-12543: query $and accepts one expression
DOCSP-4791: Certain background operations can block setFeatureCompatibilityVersion
Branch: v4.0
https://github.com/mongodb/docs/commit/90f65234bfd1a090fba330240c8d06d3d0b83b82

Comment by Githook User [ 27/Mar/19 ]

Author:

{'name': 'rk-mongo', 'email': 'ravind.kumar@mongodb.com'}

Message: Multiple small fixups:

DOCSP-4943: $cond requires all arguments
DOCS-12556: Deprecate GridFS contentType, aliases, MD5
DOCS-12543: query $and accepts one expression
DOCSP-4791: Certain background operations can block setFeatureCompatibilityVersion
Branch: v3.6
https://github.com/mongodb/docs/commit/33fec46eb47f75515d0dcf3d08746cbb35825912

Comment by Githook User [ 27/Mar/19 ]

Author:

{'name': 'rk-mongo', 'email': 'ravind.kumar@mongodb.com'}

Message: Multiple small fixups:

DOCS-12567: Removing duplicate line
DOCSP-4943: $cond requires all arguments
DOCS-12556: Deprecate GridFS contentType, aliases, MD5
DOCS-12543: query $and accepts one expression
DOCSP-4791: Certain background operations can block setFeatureCompatibilityVersion
Branch: master
https://github.com/mongodb/docs/commit/0da16c78a71ab3db1a30b9f7087b2c09bf01db44

Generated at Thu Feb 08 08:05:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.