diff --git a/java/11_find_arrays.ipynb b/java/11_find_arrays.ipynb index 7aa253e..72ddeaa 100644 --- a/java/11_find_arrays.ipynb +++ b/java/11_find_arrays.ipynb @@ -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." ] }, { diff --git a/javascript/00_open_mongodb.ipynb b/javascript/00_open_mongodb.ipynb index ee7b3b0..f7bf9f2 100644 --- a/javascript/00_open_mongodb.ipynb +++ b/javascript/00_open_mongodb.ipynb @@ -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__" ] }, { diff --git a/javascript/01_connect_database.ipynb b/javascript/01_connect_database.ipynb index 97c3b05..c1c258e 100644 --- a/javascript/01_connect_database.ipynb +++ b/javascript/01_connect_database.ipynb @@ -31,7 +31,7 @@ "metadata": {}, "outputs": [], "source": [ - "import { MongoClient } from \"npm:mongodb\";" + "import { MongoClient } from \"npm:mongodb@6.19.0\";" ] }, { @@ -161,7 +161,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.7.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/100_aggregation_pipeline_match.ipynb b/javascript/100_aggregation_pipeline_match.ipynb index d5b3e2c..b1ece11 100644 --- a/javascript/100_aggregation_pipeline_match.ipynb +++ b/javascript/100_aggregation_pipeline_match.ipynb @@ -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", @@ -236,7 +236,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/101_aggregation_pipeline_arrays.ipynb b/javascript/101_aggregation_pipeline_arrays.ipynb index c823c6d..d26a0e9 100644 --- a/javascript/101_aggregation_pipeline_arrays.ipynb +++ b/javascript/101_aggregation_pipeline_arrays.ipynb @@ -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", @@ -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", @@ -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", @@ -146,7 +154,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/102_aggregation_pipeline_unwind.ipynb b/javascript/102_aggregation_pipeline_unwind.ipynb index 7667e42..b7af453 100644 --- a/javascript/102_aggregation_pipeline_unwind.ipynb +++ b/javascript/102_aggregation_pipeline_unwind.ipynb @@ -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", @@ -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", @@ -111,7 +115,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/103_aggregation_pipeline_lookup.ipynb b/javascript/103_aggregation_pipeline_lookup.ipynb index af6a28a..e3f976a 100644 --- a/javascript/103_aggregation_pipeline_lookup.ipynb +++ b/javascript/103_aggregation_pipeline_lookup.ipynb @@ -13,7 +13,7 @@ "id": "3b936925-e295-489a-b508-2b99c0160217", "metadata": {}, "source": [ - "# Aggregation Pipeline\n", + "# Aggregation Pipeline - $lookup\n", " " ] }, @@ -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", @@ -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", @@ -110,7 +119,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/104_aggregation_pipeline_group_by.ipynb b/javascript/104_aggregation_pipeline_group_by.ipynb index 619c93c..78afc52 100644 --- a/javascript/104_aggregation_pipeline_group_by.ipynb +++ b/javascript/104_aggregation_pipeline_group_by.ipynb @@ -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", @@ -144,7 +144,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/10_find.ipynb b/javascript/10_find.ipynb index 65c8e9e..3287d35 100644 --- a/javascript/10_find.ipynb +++ b/javascript/10_find.ipynb @@ -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", @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] } ], @@ -233,7 +233,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/11_find_arrays.ipynb b/javascript/11_find_arrays.ipynb index 6798988..95c7beb 100644 --- a/javascript/11_find_arrays.ipynb +++ b/javascript/11_find_arrays.ipynb @@ -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", @@ -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", @@ -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" ] }, @@ -128,7 +128,7 @@ "outputs": [], "source": [ "const cursor = await books.find(\n", - "\t{ \"genre.name\": { $in: [\n", + "\t{ \"genres\": { $in: [\n", " \"Poetry\",\n", " \"Fiction\"\n", " ]}\n", @@ -136,7 +136,7 @@ ")\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", "});" ] }, @@ -158,7 +158,7 @@ "outputs": [], "source": [ "const cursor = await books.find(\n", - "\t{ \"genre.name\": [\n", + "\t{ \"genres\": [\n", " \"Poetry\",\n", " \"Fiction\"\n", " ]}\n", @@ -183,7 +183,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/200_full_text_search_create_index.ipynb b/javascript/200_full_text_search_create_index.ipynb index f44ee30..1edbb35 100644 --- a/javascript/200_full_text_search_create_index.ipynb +++ b/javascript/200_full_text_search_create_index.ipynb @@ -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", @@ -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": { @@ -128,7 +120,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/20_project_sort_limit.ipynb b/javascript/20_project_sort_limit.ipynb index f0ca968..f2c839b 100644 --- a/javascript/20_project_sort_limit.ipynb +++ b/javascript/20_project_sort_limit.ipynb @@ -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", @@ -168,7 +168,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/210_full_text_search.ipynb b/javascript/210_full_text_search.ipynb index 29b3c8d..d91a219 100644 --- a/javascript/210_full_text_search.ipynb +++ b/javascript/210_full_text_search.ipynb @@ -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", @@ -134,14 +134,6 @@ " console.log(`author: ${JSON.stringify(doc)}`);\n", "});" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "77abdeb3", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -157,7 +149,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/30_insert.ipynb b/javascript/30_insert.ipynb index b371723..514cd86 100644 --- a/javascript/30_insert.ipynb +++ b/javascript/30_insert.ipynb @@ -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", @@ -120,6 +120,8 @@ "metadata": {}, "outputs": [], "source": [ + "import { ObjectId } from \"npm:mongodb\";\n", + "\n", "const book = { _id: };\n", "const cursor = await books.find(book);\n", "\n", @@ -142,7 +144,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/40_delete.ipynb b/javascript/40_delete.ipynb index cfd972e..796a55f 100644 --- a/javascript/40_delete.ipynb +++ b/javascript/40_delete.ipynb @@ -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", @@ -140,7 +140,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/50_update.ipynb b/javascript/50_update.ipynb index 3df0fac..1bbe364 100644 --- a/javascript/50_update.ipynb +++ b/javascript/50_update.ipynb @@ -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", @@ -164,7 +164,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4, diff --git a/javascript/60_indexes.ipynb b/javascript/60_indexes.ipynb index dd5a351..f4bf6c4 100644 --- a/javascript/60_indexes.ipynb +++ b/javascript/60_indexes.ipynb @@ -32,7 +32,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", @@ -236,7 +236,7 @@ "name": "typescript", "nbconvert_exporter": "script", "pygments_lexer": "typescript", - "version": "5.8.3" + "version": "5.9.2" } }, "nbformat": 4,