Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion java/11_find_arrays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@
"id": "1e62db28",
"metadata": {},
"source": [
"## Don't make this mistake!"
"## Don't make this mistake!",
"\n",
"The query below will try to find books that have exactly two genres (Poetry and Fiction) in the designated order. The query looks for an exact match of the array. Usually we want to search inside the array."
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions javascript/00_open_mongodb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"- admin\n",
"- config\n",
"- local\n",
"- library -> __we're going to work with this one__\n",
"- library_with_embedding -> same data, but books have vector embedding for vector search"
"- library -> __we're going to work with this one__"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions javascript/01_connect_database.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"import { MongoClient } from \"npm:mongodb\";"
"import { MongoClient } from \"npm:mongodb@6.19.0\";"
]
},
{
Expand Down Expand Up @@ -161,7 +161,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.7.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions javascript/100_aggregation_pipeline_match.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -236,7 +236,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
40 changes: 24 additions & 16 deletions javascript/101_aggregation_pipeline_arrays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb@6.16\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -79,13 +79,17 @@
"source": [
"// Aggregation pipeline\n",
"const pipeline = [\n",
" { $match: {\n",
" 'genre.name': { $all: ['Police', 'Fiction'] }\n",
" } },\n",
" { $project: {\n",
" title: 1,\n",
" genre: 1\n",
" } }\n",
" {\n",
" $match: {\n",
" genres: { $all: [\"Police\", \"Fiction\"] },\n",
" },\n",
" },\n",
" {\n",
" $project: {\n",
" title: 1,\n",
" genre: 1,\n",
" },\n",
" },\n",
"];\n",
"\n",
"// Execute the aggregate operation\n",
Expand Down Expand Up @@ -114,13 +118,17 @@
"source": [
"// Aggregate pipeline\n",
"const pipeline = [\n",
" { $match: {\n",
" 'genre.name': { $in: ['Police', 'Fiction'] }\n",
" } },\n",
" { $project: {\n",
" title: 1,\n",
" genre: 1\n",
" } }\n",
" {\n",
" $match: {\n",
" genres: { $in: [\"Police\", \"Fiction\"] },\n",
" },\n",
" },\n",
" {\n",
" $project: {\n",
" title: 1,\n",
" genre: 1,\n",
" },\n",
" },\n",
"];\n",
"\n",
"// Execute the aggregate operation\n",
Expand All @@ -146,7 +154,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
24 changes: 14 additions & 10 deletions javascript/102_aggregation_pipeline_unwind.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb@6.16\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -78,14 +78,18 @@
"source": [
"// Aggregation pipeline\n",
"const pipeline = [\n",
" { $match: {\n",
" \"_id\": \"60187778\"\n",
" } },\n",
" { $unwind: \"$attributes\" },\n",
" { $project: {\n",
" title: 1,\n",
" attributes: 1\n",
" } }\n",
" {\n",
" $match: {\n",
" _id: \"0060930284\",\n",
" },\n",
" },\n",
" { $unwind: \"$attributes\" },\n",
" {\n",
" $project: {\n",
" title: 1,\n",
" attributes: 1,\n",
" },\n",
" },\n",
"];\n",
"\n",
"// Execute the aggregate operation\n",
Expand All @@ -111,7 +115,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
31 changes: 20 additions & 11 deletions javascript/103_aggregation_pipeline_lookup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"id": "3b936925-e295-489a-b508-2b99c0160217",
"metadata": {},
"source": [
"# Aggregation Pipeline\n",
"# Aggregation Pipeline - $lookup\n",
" "
]
},
Expand All @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb@6.16\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -77,14 +77,23 @@
"source": [
"// Aggregation pipeline\n",
"const pipeline = [\n",
" {$lookup: {\n",
" from: \"books\", // read from books collection\n",
" localField: \"books\", // authors have a books array with books ids\n",
" foreignField: \"_id\", // join using the _id field\n",
" as: \"booksWritten\" // add a new field with the results\n",
" } },\n",
" {$limit: 10},\n",
" {$project: {_id: 0}}\n",
" {\n",
" $lookup: {\n",
" from: \"books\", // read from books collection\n",
" localField: \"books\", // authors have a books array with books ids\n",
" foreignField: \"_id\", // join using the _id field\n",
" as: \"booksWritten\", // add a new field with the results\n",
" },\n",
" },\n",
" { $limit: 10 },\n",
" {\n",
" $project: {\n",
" _id: 0,\n",
" title: 1,\n",
" books: 1,\n",
" booksWritten: 1,\n",
" },\n",
" },\n",
"];\n",
"\n",
"// Execute the aggregate operation\n",
Expand All @@ -110,7 +119,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions javascript/104_aggregation_pipeline_group_by.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -144,7 +144,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions javascript/10_find.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -176,7 +176,7 @@
"metadata": {},
"outputs": [],
"source": [
"// type in your code here, you'll need to adapt the code a bit\n"
"// type in your code here\n"
]
},
{
Expand All @@ -196,7 +196,7 @@
"metadata": {},
"outputs": [],
"source": [
"// type in your code here, you'll need to adapt the code a bit\n"
"// type in your code here\n"
]
},
{
Expand All @@ -216,7 +216,7 @@
"metadata": {},
"outputs": [],
"source": [
"// type in your code here, you'll need to adapt the code a bit\n"
"// type in your code here\n"
]
}
],
Expand All @@ -233,7 +233,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
18 changes: 9 additions & 9 deletions javascript/11_find_arrays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb@6.16\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -76,7 +76,7 @@
"outputs": [],
"source": [
"const cursor = await books.find(\n",
"\t{ \"genre.name\": \"Poetry\"}\n",
"\t{ \"genres\": \"Poetry\"}\n",
")\n",
"\n",
"await cursor.forEach((book) => {\n",
Expand All @@ -100,15 +100,15 @@
"outputs": [],
"source": [
"const cursor = await books.find(\n",
"\t{ \"genre.name\": { $all: [\n",
" \"Poetry\",\n",
"\t{ \"genres\": { $all: [\n",
" \"Family Life\",\n",
" \"Fiction\"\n",
" ]}\n",
" }\n",
")\n",
"\n",
"await cursor.forEach((book) => {\n",
" console.log(book.title + \" - \" + JSON.stringify(book.genre));\n",
" console.log(book.title + \" - \" + JSON.stringify(book.genres));\n",
"});\n"
]
},
Expand All @@ -128,15 +128,15 @@
"outputs": [],
"source": [
"const cursor = await books.find(\n",
"\t{ \"genre.name\": { $in: [\n",
"\t{ \"genres\": { $in: [\n",
" \"Poetry\",\n",
" \"Fiction\"\n",
" ]}\n",
" }\n",
")\n",
"\n",
"await cursor.forEach((book) => {\n",
" console.log(book.title + \" - \" + JSON.stringify(book.genre));\n",
" console.log(book.title + \" - \" + JSON.stringify(book.genres));\n",
"});"
]
},
Expand All @@ -158,7 +158,7 @@
"outputs": [],
"source": [
"const cursor = await books.find(\n",
"\t{ \"genre.name\": [\n",
"\t{ \"genres\": [\n",
" \"Poetry\",\n",
" \"Fiction\"\n",
" ]}\n",
Expand All @@ -183,7 +183,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
12 changes: 2 additions & 10 deletions javascript/200_full_text_search_create_index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"// Import the MongoDB Driver\n",
"import { MongoClient } from \"npm:mongodb\";\n",
"import { MongoClient } from \"npm:mongodb@6.19.0\";\n",
"\n",
"// Set your connection String\n",
"const mongoDBURI =\n",
Expand Down Expand Up @@ -105,14 +105,6 @@
"const indexes = await books.listSearchIndexes().toArray();\n",
"console.log(\"Indexes:\", indexes);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "219aae92",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -128,7 +120,7 @@
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.8.3"
"version": "5.9.2"
}
},
"nbformat": 4,
Expand Down
Loading