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: docs/40-CRUD/1-WHERE.mdx
+17-17
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
# 👐 WHERE → .find()
2
2
3
-
Similar to SQL's `WHERE` clause, the `.find()` method in MongoDB retrieves documents from a collection that match a specified query.
3
+
Similar to SQL's `WHERE` clause, the `.find()` method in MongoDB retrieves documents from a collection that matches a specified query.
4
4
5
5
## Syntax
6
6
7
7
```js
8
8
db.collection.find({ <query> })
9
9
```
10
10
11
-
-`<query>`: Specifies conditions to filter documents.
11
+
-`<query>`: Specifies conditions to filter documents
12
12
13
13
## Example: Find all books from 2020
14
14
15
15
```js
16
16
db.books.find({ year:2020 });
17
17
```
18
18
19
-
### Equivalent SQL Query
19
+
### Equivalent SQL query
20
20
21
21
```sql
22
22
SELECT*FROM books WHERE year =2020;
@@ -26,24 +26,24 @@ SELECT * FROM books WHERE year = 2020;
26
26
27
27
The `find()` method takes a document as its first argument. This document specifies the filter criteria. You can use a variety of expressions within the filter document:
28
28
29
-
-**Comparison Operators:**`$eq` (equals), `$ne` (not equals), `$gt` (greater than), `$lt` (less than), `$gte` (greater than or equals), `$lte` (less than or equals), `$in` (in an array), `$nin` (not in an array).
30
-
-**Logical Operators:**`$and`, `$or`, `$not`.
31
-
-**Element Operators:**`$exists` (check for field existence), `$type` (check data type).
-**Geo-spatial Operators:** For location-based queries.
34
-
-**Array Operators:** For querying arrays.
29
+
-**Comparison operators:**`$eq` (equals), `$ne` (not equals), `$gt` (greater than), `$lt` (less than), `$gte` (greater than or equals), `$lte` (less than or equals), `$in` (in an array), `$nin` (not in an array)
30
+
-**Logical operators:**`$and`, `$or`, `$not`
31
+
-**Element operators:**`$exists` (check for field existence), `$type` (check data type)
0 commit comments