Skip to content

Commit 7e64eba

Browse files
Merge pull request #7 from Meg528/patch-9
Update 5-UPDATE.mdx
2 parents abc59c0 + 729db8e commit 7e64eba

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/40-CRUD/5-UPDATE.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ db.collection.updateOne(
1515
)
1616
```
1717

18-
- `<query>`: Specifies which document to update.
18+
- `<query>`: Specifies which document to update
1919

2020
- `<update operation>`: Defines modifications using update operators like $set, $inc, etc.
2121

22-
- `<options>`: (Optional) Allows additional configurations like upsert: true.
22+
- `<options>`: (Optional) Allows additional configurations like upsert: true
2323

2424
## Example: Update a book
2525

@@ -30,15 +30,15 @@ db.reviews.updateOne(
3030
);
3131
```
3232

33-
### Equivalent SQL Query
33+
### Equivalent SQL query
3434

3535
```sql
3636
UPDATE reviews SET rating = 5 WHERE bookId = '0312979509';
3737
```
3838

3939
## Upsert option
4040

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.
4242

4343
```js
4444
db.reviews.updateOne(
@@ -47,9 +47,9 @@ db.reviews.updateOne(
4747
);
4848
```
4949

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.
5151
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.
5353

5454
```js
5555
db.reviews.updateOne(
@@ -61,7 +61,7 @@ db.reviews.updateOne(
6161

6262
:::info
6363

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:
6565

6666
```js
6767
{

0 commit comments

Comments
 (0)