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/$and.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.author: suvishod
7
7
ms.service: azure-cosmos-db
8
8
ms.subservice: mongodb-vcore
9
9
ms.topic: language-reference
10
-
ms.date: 08/04/2025
10
+
ms.date: 09/04/2025
11
11
---
12
12
13
13
# $and
@@ -36,7 +36,7 @@ The `$and` operator performs a logical AND operation on an array of expressions
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 AND operator as logical-query
152
152
153
-
The query filters for stores where the number of full-time employees is greater than 10 and part-time employees is less than 15 using the `$and` operator. It projects only the `name` and `staff` fields and limits the result to three records.
153
+
This query filters for stores where the number of full-time employees is greater than 10 and part-time employees is less than 15 using the `$and` operator. It projects only the `name` and `staff` fields and limits the result to three records.
154
154
155
155
```javascript
156
156
db.stores.find({
@@ -169,7 +169,7 @@ db.stores.find({
169
169
}).limit(3)
170
170
```
171
171
172
-
The query returns up to three stores with high full-time but limited part-time staffing.
172
+
The first three results returned by this query are:
173
173
174
174
```json
175
175
[
@@ -208,7 +208,7 @@ The query returns up to three stores with high full-time but limited part-time s
208
208
209
209
### Example 2: Use AND operator as boolean-expression to find stores with high sales and sufficient staff
210
210
211
-
The example finds stores that have both total sales greater than 100,000 and more than 30 total staff members.
211
+
This query finds stores that have both total sales greater than 100,000 and more than 30 total staff members.
212
212
213
213
```javascript
214
214
db.stores.aggregate([
@@ -231,9 +231,10 @@ db.stores.aggregate([
231
231
])
232
232
```
233
233
234
-
The query returns stores that meet both high sales and staffing criteria.
234
+
The first two results returned by this query are:
235
235
236
236
```json
237
+
[
237
238
{
238
239
"_id": "905d1939-e03a-413e-a9c4-221f74055aac",
239
240
"name": "Trey Research | Home Office Depot - Lake Freeda",
@@ -246,6 +247,7 @@ The query returns stores that meet both high sales and staffing criteria.
0 commit comments