Skip to content

Commit 4c46d0f

Browse files
committed
Added changes
1 parent d088af4 commit 4c46d0f

28 files changed

+864
-468
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Import a Library data
1+
# Import Library data
22

33
We'll import a library dataset, with Author, Book and reviews information.
44

5-
- copy the [Connection String](https://www.mongodb.com/docs/manual/reference/connection-string/) from your MongoDB cluster
5+
- 💻 copy the [Connection String](https://www.mongodb.com/docs/manual/reference/connection-string/) from your MongoDB cluster
66
- make sure to grant network access from everywhere
7-
- go to https://library-scripts-ofiejy7uia-uc.a.run.app/, run the import
7+
- 💻 go to https://library-scripts-ofiejy7uia-uc.a.run.app/, run the import

docs/1-mongodb-atlas/get-started-atlas.mdx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,15 @@ Next, deploy your forever-free cloud database in MongoDB Atlas.
1818

1919
1. Click on the **Build a Database** button.
2020

21-
<img
22-
alt="'Create a database' section in MongoDB Atlas highlighting the 'Build a database' button"
23-
src={useBaseUrl('/img/chapter-1-mongodb-atlas/create-a-database.png')}
24-
width="500"
25-
/>
21+
<Screenshot src="/img/chapter-1-mongodb-atlas/create-a-database.png" url="https://cloud.atlas.com" alt="'Create a database' section in MongoDB Atlas highlighting the 'Build a database' button" />
2622

2723
1. Select **M0** — the free shared tier.
2824

29-
<img
30-
alt="Database type selection section highlighting the M0 option"
31-
src={useBaseUrl('/img/chapter-1-mongodb-atlas/select-database-type.png')}
32-
/>
25+
<Screenshot src="/img/chapter-1-mongodb-atlas/select-database-type.png" url="https://cloud.atlas.com" alt="Database type selection section highlighting the M0 option" />
3326

3427
1. Select a cloud provider and a region close to you. Rename your database to **AtlasSearchSoccer**.
3528

36-
<img
37-
alt="Configuration settings for cloud provider, region and database name"
38-
src={useBaseUrl('/img/chapter-1-mongodb-atlas/select-cloud-provider-region-name.png')}
39-
/>
29+
<Screenshot src="/img/chapter-1-mongodb-atlas/select-cloud-provider-region-name.png" url="https://cloud.atlas.com" alt="Configuration settings for cloud provider, region and database name" />
4030

4131
1. Click **Create** to deploy your database.
4232

docs/30-simple-queries/3-project.mdx

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,81 @@ A document from the `books` collection looks like:
66

77
```js
88
{
9-
_id: '0452264464',
10-
title: 'Beloved (Plume Contemporary Fiction)',
9+
_id: '0765342502',
10+
title: 'The Green Brain',
1111
authors: [
1212
{
13-
_id: '64cc2db4830ba29148da4c4e',
14-
name: 'Toni Morrison'
13+
_id: '64cc2db4830ba29148da52be',
14+
name: 'Frank Herbert'
1515
}
1616
],
17-
pages: 288,
18-
year: 1998,
19-
cover: 'https://images.isbndb.com/covers/44/65/9780452264465.jpg',
17+
pages: 224,
18+
year: 2002,
19+
synopsis: 'a Fascinating Examination Of The Fragile Balance Between Consciousness, Man, And Insect From One Of The Best-loved Science Fiction Creators Of All Time.',
20+
cover: 'https://images.isbndb.com/covers/25/08/9780765342508.jpg',
2021
attributes: [
21-
{
22-
key: 'publisher',
23-
value: 'Longman'
24-
},
25-
{
26-
key: 'language',
27-
value: 'en'
28-
},
29-
{
30-
key: 'image',
31-
value: 'https://images.isbndb.com/covers/44/65/9780452264465.jpg'
32-
},
33-
{
34-
key: 'title_long',
35-
value: 'Beloved (Plume Contemporary Fiction)'
36-
},
3722
{
3823
key: 'edition',
39-
value: 'Reissue'
24+
value: '1st'
4025
},
4126
{
4227
key: 'dimensions',
43-
value: 'Height: 8 Inches, Length: 5.46 Inches, Weight: 0.57981574906 Pounds, Width: 0.67 Inches'
44-
},
45-
{
46-
key: 'date_published',
47-
value: '1998'
28+
value: 'Height: 1.111 Inches, Length: 1.111 Inches, Weight: 0.2 Pounds, Width: 1.111 Inches'
4829
},
4930
{
5031
key: 'isbn13',
51-
value: '9780452264465'
32+
value: '9780765342508'
5233
},
5334
{
5435
key: 'msrp',
55-
value: 6.67
56-
},
57-
{
58-
key: 'binding',
59-
value: 'Paperback'
36+
value: 6.99
6037
},
6138
{
6239
key: 'isbn',
63-
value: '0452264464'
40+
value: '0765342502'
6441
},
6542
{
6643
key: 'isbn10',
67-
value: '0452264464'
44+
value: '0765342502'
45+
}
46+
],
47+
totalInventory: 1,
48+
available: 1,
49+
binding: 'Mass Market Paperback',
50+
language: 'en',
51+
longTitle: 'The Green Brain',
52+
publisher: 'Tor Books',
53+
reviews: [
54+
{
55+
text: 'I absolutely loved this book! The characters were well-developed and the plot was gripping. The writing style was engaging and kept me hooked until the very end. Highly recommend!',
56+
rating: 4,
57+
name: 'Phoebe Silva',
58+
timestamp: 2023-03-30T11:56:44.519Z,
59+
_id: ObjectId("6511eb21ace76077e045b2d7")
60+
},
61+
{
62+
text: 'I really enjoyed this book. The story kept me engaged from beginning to end and the characters were well-developed. The writing style was captivating and the plot had several unexpected twists and turns. Overall, a great read that I would highly recommend!',
63+
rating: 4,
64+
name: 'عرشيا کوتی',
65+
timestamp: 2022-05-30T15:15:43.377Z,
66+
_id: ObjectId("6511eb20ace76077e045b2d5")
6867
},
6968
{
70-
key: 'other_isbns',
71-
value: [
72-
{
73-
isbn: '9780307794802',
74-
binding: 'print'
75-
}
76-
]
69+
text: "This book is an absolute masterpiece. The storytelling is captivating and the characters are so well-developed. I couldn't put it down and found myself fully immersed in the story from beginning to end. The writing style is beautiful and the plot twists kept me on the edge of my seat. I highly recommend this book to anyone who enjoys a thought-provoking and emotionally charged read. It's truly a gem!",
70+
rating: 5,
71+
name: 'Malo Lecomte',
72+
timestamp: 2021-08-27T20:34:33.710Z,
73+
_id: ObjectId("6511eb21ace76077e045b2d6")
7774
}
7875
],
79-
totalInventory: 2,
80-
available: 2
76+
vectorizedSynopsis: [
77+
0.020951554,
78+
0.001816311,
79+
0.00775048,
80+
-0.01312131,
81+
0.01894414,
82+
0.006397802,
83+
-0.027944269,
8184
}
8285
```
8386

docs/30-simple-queries/6-writing-long-pipelines.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,16 @@ db.books.aggregate([
2828

2929
Easier to read, and reason about, right?
3030

31+
💻 Try to run the above pipeline and compare your results: should be the same
32+
3133
:::tip
3234

3335
Write your aggregation pipelines like you'll compose functions in your programming language. Aggregations _are_ code that runs on the server. In the client you just express _what_ you want to be done, not _how_ to do it.
3436

37+
:::
38+
39+
:::tip
40+
41+
As this is code, we can even add comments (starting with `//`) to our pipelines
42+
3543
:::

docs/30-simple-queries/7-repeating-stages.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@ So we can repeat most stages, and do something like this to get all books from 2
1414
```js
1515
db.books.aggregate([{$match: {pages: 100}}, {$match: {year: 2011}}])
1616
```
17+
18+
19+
20+
💻 Add several `$limt` stages at the end of the above aggregation, limiting to 1 book and see what happens
21+
22+
<details>
23+
<summary>Answer</summary>
24+
<div>
25+
26+
```js
27+
db.books.aggregate([
28+
{$match: {pages: 100}},
29+
{$match: {year: 2011}},
30+
{$limit: 1},
31+
{$limit: 1},
32+
])
33+
```
34+
</div>
35+
</details>

docs/40-counting-sorting/1-counting-documents.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ Here, `$count` will count the resulting docs and will return a document with jus
3838
}
3939
```
4040

41+
42+
💻 How many authors do we have in our `authors` collection?
43+
44+
<details>
45+
<summary>Answer</summary>
46+
<div>
47+
48+
```js
49+
db.authors.aggregate([{$count: "authorCount"}])
50+
```
51+
</div>
52+
</details>
53+
4154
## The order of stages is important
4255

4356
If we count after the `$match` stage, the document we're passing to the next steps contains only the `totalBooks` field. So the `$project` will return an empty document.

docs/40-counting-sorting/10-sorting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sorting
22

3-
We can sort our results using the `$sort` stage:
3+
We can sort our results using the `$sort` stage. We need to sort on a field, being 1 ascending and -1 descending order.
44

55
Let's get all books from 1984, sorted by number of pages. We'll only show the title, pages and authors.
66

docs/50-using-arrays/1-matching-arrays.mdx

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)