You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/mongodb/vcore/operators/logical-query/$or.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ The `$or` operator performs a logical OR operation on an array of expressions an
36
36
37
37
## Examples
38
38
39
-
Let's understand the usage with sample json from `stores` dataset.
39
+
Consider this sample document from the stores collection.
40
40
41
41
```json
42
42
{
@@ -150,7 +150,7 @@ Let's understand the usage with sample json from `stores` dataset.
150
150
151
151
### Example 1: Use OR operation as logical-query
152
152
153
-
The example helps to find stores with more than 15 full-time staff or more than 20 part-time staff, run a query using the $or operator on both the conditions. Then, project only the name and staff fields from the stores in the result set.
153
+
This query retrieves stores with more than 15 full-time staff or more than 20 part-time staff, run a query using the $or operator on both the conditions. Then, project only the name and staff fields from the stores in the result set.
154
154
155
155
```javascript
156
156
db.stores.find(
@@ -167,9 +167,10 @@ db.stores.find(
167
167
).limit(2)
168
168
```
169
169
170
-
The query returns up to two store documents showing only their name and staff details, filtered by employee count criteria.
170
+
The first two results returned by this query are:
171
171
172
172
```json
173
+
[
173
174
{
174
175
"_id": "dda2a7d2-6984-40cc-bbea-4cbfbc06d8a3",
175
176
"name": "Contoso, Ltd. | Home Improvement Closet - Jaskolskiview",
@@ -190,11 +191,12 @@ The query returns up to two store documents showing only their name and staff de
190
191
}
191
192
}
192
193
}
194
+
]
193
195
```
194
196
195
197
### Example 2: Use OR operator as boolean-expression to identify stores with either high sales or large staff
196
198
197
-
The example finds stores that have either total sales greater than 50,000 or more than 25 total staff members.
199
+
This query retrieves stores that have either total sales greater than 50,000 or more than 25 total staff members.
198
200
199
201
```javascript
200
202
db.stores.aggregate([
@@ -217,9 +219,10 @@ db.stores.aggregate([
217
219
])
218
220
```
219
221
220
-
The query returns stores that meet either the sales or staffing criteria.
222
+
The first four results returned by this query are:
221
223
222
224
```json
225
+
[
223
226
{
224
227
"_id": "905d1939-e03a-413e-a9c4-221f74055aac",
225
228
"name": "Trey Research | Home Office Depot - Lake Freeda",
@@ -244,6 +247,7 @@ The query returns stores that meet either the sales or staffing criteria.
244
247
"totalStaff": 2,
245
248
"qualifiesForProgram": false
246
249
}
250
+
]
247
251
```
248
252
249
253
## Performance Considerations
@@ -258,3 +262,4 @@ The query returns stores that meet either the sales or staffing criteria.
0 commit comments