-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $size #354
Merged
Merged
Add $size #354
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
36318d8
Add section Equality handling with arrays and subdocs
johnsmartco c40c1ca
add
johnsmartco ea390b5
Inc comments from Mahesh
johnsmartco bab9bcd
Add
johnsmartco 80cb049
minor edit
johnsmartco 5992f51
Merge branch 'main' into c2-2459
johnsmartco 98fc6cc
remove logical operator example
johnsmartco aad3b22
Inc correction from Mahesh
johnsmartco 4c3ff9e
Inc correction from Mahesh
johnsmartco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1419,26 +1419,22 @@ The `$all` operation allows users to check for documents that have an array fiel | |
|
||
If provided to a `find()`, return all the documents where the locations field contains the two values – “New York” and “Texas”. It does not matter how many more values the locations field contains. The operation will match if the specified values are present. Similarly, if even one the value is missing, the document will not be matched. So the `$all` operation is useful while retrieving data. | ||
|
||
The `$all` is equivalent to an `$and` operation of the specified values. For example, this first statement: | ||
#### $elemMatch operation | ||
|
||
```json5 | ||
{ tags: { $all: [ "ssl" , "security" ] } } | ||
``` | ||
TODO: | ||
|
||
... is equivalent to: | ||
#### $size operation | ||
|
||
```json5 | ||
{ $and: [ { tags: "ssl" }, { tags: "security" } ] } | ||
The `$size` operation allows users to match any array with the number of elements specified by the argument. Example: | ||
|
||
```json5 | ||
db.collection.find( { field: { $size: 2 } } ); | ||
``` | ||
|
||
#### $elemMatch operation | ||
|
||
TODO: | ||
That expression returns, e.g.: `{ field: [ red, green ] }` and `{ field: [ apple, lime ] }`, but not `{ field: fruit }` or `{ field: [ orange, lemon, grapefruit ] }`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quotes around "field" and string values, so |
||
|
||
#### $size operation | ||
If the given field is not an array, there's no match. `$size` should ignore non-arrays. | ||
|
||
TODO: | ||
|
||
### Projection Clause | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't valid JSON. I think this should be
{ "field": { "$size": 2 } }