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
This is a template to __create new Lab documentation sites__. Contains info on how to use Docusaurus and is a good starting point.
4
-
5
-
### Installation, use, how to build, etc.
6
-
7
-
Everything is covered in the Lab itself: https://mongodb-developer.github.io/docusaurus-workshop/
8
-
9
-
## Contributing
10
-
11
-
As `main` is protected, submit a pull request to be reviewed.
12
-
13
-
## Docusaurus
14
-
15
-
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. It's available on https://mongodb-developer.github.io/docusaurus-workshop/.
16
-
17
-
### Disclaimer
18
-
19
-
Use at your own risk; not a supported MongoDB product
Copy file name to clipboardExpand all lines: docs/20-prerequisites/20-prerequisite.mdx
+4-3
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,8 @@ description: Setting up your MongoDB Atlas account, importing Library data
6
6
7
7
To follow along, you'll need to complete the first two labs of the MongoDB for RDBMS professionals, which will help you in getting:
8
8
9
-
- A MongoDB Atlas cluster.
10
-
- Test data. In this case, this is book, author, and review data for a library management system.
11
9
12
-
👐 To get both, open the [intro lab](https://mongodb-developer.github.io/intro-lab/docs/intro) and follow it (only takes 10-15 mins) to get your database ready. Return here when finished!
10
+
- A free MongoDB Atlas Cluster
11
+
- Sample library data
12
+
13
+
To get both, open the [intro lab](https://mongodb-developer.github.io/intro-lab/docs/intro) and follow it (only takes 10-15 mins) to get your database ready. Return here when finished!
To use work through the exercises, we need to install the official MongoDB GUI:[Download and Install Compass](https://www.mongodb.com/try/download/compass)
7
+
To use work through the exercises, we need to install the official MongoDB GUI.[Download and install Compass](https://www.mongodb.com/try/download/compass).
8
8
9
-
## Connect compass to your Atlas cluster
9
+
## Connect Compass to your Atlas cluster
10
10
11
-
- Insert Add connection page of compass
11
+
### 1. Click on the "Add connection" button on the home page
12
12
13
-
## Select the library database
13
+

14
14
15
-
- Insert databases list
15
+
### 2. Paste your connection string after updating your password and click on the "Save and Connect" button
16
+
17
+

18
+
19
+
### 3. Select the library database
20
+
21
+

22
+
23
+
### 4. Click on the "Open MongoDB shell" button
24
+
25
+

26
+
27
+
### 5. Switch to the library database in the shell
28
+
29
+
Once the shell is loaded, execute: `use library` to ensure you are in the correct database.
30
+
31
+

32
+
33
+
That's it for the setup, let's get our hands dirty!
Copy file name to clipboardExpand all lines: docs/40-CRUD/1-WHERE.mdx
+18-18
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)
Copy file name to clipboardExpand all lines: docs/40-CRUD/5-UPDATE.mdx
+7-7
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,11 @@ db.collection.updateOne(
15
15
)
16
16
```
17
17
18
-
-`<query>`: Specifies which document to update.
18
+
-`<query>`: Specifies which document to update
19
19
20
20
-`<update operation>`: Defines modifications using update operators like $set, $inc, etc.
21
21
22
-
-`<options>`: (Optional) Allows additional configurations like upsert: true.
22
+
-`<options>`: (Optional) Allows additional configurations like upsert: true
23
23
24
24
## Example: Update a book
25
25
@@ -30,15 +30,15 @@ db.reviews.updateOne(
30
30
);
31
31
```
32
32
33
-
### Equivalent SQL Query
33
+
### Equivalent SQL query
34
34
35
35
```sql
36
36
UPDATE reviews SET rating =5WHERE bookId ='0312979509';
37
37
```
38
38
39
39
## Upsert option
40
40
41
-
Let's say, we want to update a review in our database from "John" for the book "0312979509" by rating it 5 stars.
41
+
Let's say we want to update a review in our database from "John" for the book "0312979509" by rating it 5 stars.
42
42
43
43
```js
44
44
db.reviews.updateOne(
@@ -47,9 +47,9 @@ db.reviews.updateOne(
47
47
);
48
48
```
49
49
50
-
Suppose "John" had never posted a review for this book before, the above query won't really do anything.
50
+
Suppose "John" had never posted a review for this book before. The above query won't really do anything.
51
51
In some cases, we may want to store a fresh new review based on the condition and updates mentioned in query.
52
-
To handle such scenarios in MongoDB, we don't have to write additional application code to achieve this, all we have to do is- utilize the `upsert` option.
52
+
To handle such scenarios in MongoDB, we don't have to write additional application code to achieve this. All we have to do is utilize the `upsert` option.
53
53
54
54
```js
55
55
db.reviews.updateOne(
@@ -61,7 +61,7 @@ db.reviews.updateOne(
61
61
62
62
:::info
63
63
64
-
Executing the above command, will insert a fresh new document in the collection like this:
64
+
Executing the above command will insert a fresh new document in the collection, like this:
0 commit comments