diff --git a/config/redirects b/config/redirects index 9e0ebe1b0..c3bf92878 100644 --- a/config/redirects +++ b/config/redirects @@ -10,6 +10,7 @@ raw: ${prefix}/stable -> ${base}/current/ [*-master]: ${prefix}/${version}/fundamentals/versioned-api/ -> ${base}/${version}/fundamentals/stable-api/ [*-master]: ${prefix}/${version}/fundamentals/connection/lambda/ -> ${base}/${version}/fundamentals/connection/ [*-master]: ${prefix}/${version}/fundamentals/csfle -> ${base}/${version}/fundamentals/encrypt-fields/ +[*-master]: ${prefix}/${version}/faq/ -> ${base}/${version}/ [*-v5.0]: ${prefix}/${version}/quick-start/connect-to-mongodb/ -> ${base}/${version}/quick-start/ [*-v5.0]: ${prefix}/${version}/quick-start/create-a-connection-string/ -> ${base}/${version}/quick-start/ @@ -23,4 +24,71 @@ raw: ${prefix}/stable -> ${base}/current/ [*-v5.5]: ${prefix}/${version}/fundamentals/run-command/ -> ${base}/${version}/usage-examples/command/ [*-master]: ${prefix}/${version}/fundamentals/crud/write-operations/change-a-document/ -> ${base}/${version}/fundamentals/crud/write-operations/modify/ -[*-v6.0): ${prefix}/${version}/fundamentals/connection/socks/ -> ${base}/${version}/ +[*-v6.0]: ${prefix}/${version}/fundamentals/connection/socks/ -> ${base}/${version}/ + +# Comprehensive Coverage Redirects + +[v6.5-master]: ${prefix}/${version}/quick-start/download-and-install/ -> ${base}/${version}/get-started/ +[v6.5-master]: ${prefix}/${version}/quick-start/create-a-deployment/ -> ${base}/${version}/get-started/ +[v6.5-master]: ${prefix}/${version}/quick-start/create-a-connection-string/ -> ${base}/${version}/get-started/ +[v6.5-master]: ${prefix}/${version}/quick-start/connect-to-mongodb/ -> ${base}/${version}/get-started/ +[v6.5-master]: ${prefix}/${version}/quick-start/next-steps/ -> ${base}/${version}/get-started/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/ -> ${base}/${version}/connect/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/connect/ -> ${base}/${version}/connect/mongoclient/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/connection-options/ -> ${base}/${version}/connect/connection-options/ +[v6.5-master]: ${prefix}/${version}/connection-troubleshooting/ -> ${base}/${version}/connect/connection-troubleshooting/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/network-compression/ -> ${base}/${version}/connect/connection-options/network-compression/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/csot/ -> ${base}/${version}/connect/connection-options/csot/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/bulk/ -> ${base}/${version}/crud/bulk-write/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/insert/ -> ${base}/${version}/crud/insert/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/upsert/ -> ${base}/${version}/crud/update/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/delete/ -> ${base}/${version}/crud/delete/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/ -> ${base}/${version}/crud/query/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/query-document/ -> ${base}/${version}/crud/query/query-document/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/compound-operations/ -> ${base}/${version}/crud/compound-operations/ + +[v6.5-v6.15]: ${prefix}/${version}/fundamentals/crud/read-write-pref/ ->${base}/${version}/crud/read-write-pref/ + +[v6.5-master]: ${prefix}/${version}/fundamentals/transactions/ -> ${base}/${version}/crud/transactions/ +[v6.5-master]: ${prefix}/${version}/fundamentals/gridfs/ -> ${base}/${version}/crud/gridfs/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/retrieve/ -> ${base}/${version}/crud/query/retrieve/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/project/ -> ${base}/${version}/crud/query/project/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/distinct/ -> ${base}/${version}/crud/query/distinct/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/cursor/ -> ${base}/${version}/crud/query/cursor/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/geo/ -> ${base}/${version}/crud/query/geo/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/time-series/ -> ${base}/${version}/data-formats/time-series/ +[v6.5-master]: ${prefix}/${version}/fundamentals/bson/ -> ${base}/${version}/data-formats/bson/ +[v6.5-master]: ${prefix}/${version}/fundamentals/indexes/ -> ${base}/${version}/indexes/ +[v6.5-master]: ${prefix}/${version}/fundamentals/run-command/ -> ${base}/${version}/run-command/ +[v6.5-master]: ${prefix}/${version}/fundamentals/monitoring/ -> ${base}/${version}/monitoring-and-logging/monitoring/ +[v6.5-master]: ${prefix}/${version}/fundamentals/logging/ -> ${base}/${version}/monitoring-and-logging/logging/ +[v6.5-master]: ${prefix}/${version}/usage-examples/changeStream -> ${base}/monitoring-and-logging/change-streams/ +[v6.5-master]: ${prefix}/${version}/fundamentals/aggregation/ -> ${base}/${version}/aggregation/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/ -> ${base}/aggregation/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/filtered-subset/ -> ${base}/aggregation/filtered-subset/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/group-total/ -> ${base}/aggregation/group-total/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/multi-field-join/ -> ${base}/aggregation/multi-field-join/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/one-to-one-join/ -> ${base}/aggregation/one-to-one-join/ +[v6.5-master]: ${prefix}/${version}/aggregation-tutorials/unpack-arrays/ -> ${base}/aggregation/unpack-arrays/ +[v6.5-master]: ${prefix}/${version}/fundamentals/authentication -> ${base}/security/authentication/ + +[v6.5-v6.15]: ${prefix}/${version}/fundamentals/authentication/mechanisms/ -> ${base}/security/authentication/mechanisms/ + +[v6.5-v6.15]: ${prefix}/${version}/fundamentals/authentication/enterprise-mechanisms/ -> ${base}/security/authentication/enterprise-mechanisms/ + +[v6.5-master]: ${prefix}/${version}/fundamentals/encrypt-fields/ -> ${base}/security/encrypt-fields/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/tls/ -> ${base}/security/tls/ +[v6.5-master]: ${prefix}/${version}/fundamentals/connection/socks/ -> ${base}/security/socks/ +[v6.5-master]: ${prefix}/${version}/fundamentals/typescript/ -> ${base}/typescript/ +[v6.5-master]: ${prefix}/${version}/whats-new/ -> ${base}/reference/release-notes/ +[v6.5-master]: ${prefix}/${version}/compatibility/ -> ${base}/reference/compatibility/ +[v6.5-master]: ${prefix}/${version}/upgrade/ -> ${base}/reference/upgrade/ +[v6.5-master]: ${prefix}/${version}/quick-reference/ -> ${base}/reference/quick-reference/ + +[v6.5-v6.15]: ${prefix}/${version}/fundamentals/collations/ -> ${base}/crud/collations/ + +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/read-operations/text/ -> ${base}/crud/query/text/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/modify/ -> ${base}/crud/update/modify/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/embedded-arrays/ -> ${base}/crud/update/embedded-arrays/ +[v6.5-master]: ${prefix}/${version}/fundamentals/crud/write-operations/pkFactory/ -> ${base}/crud/pkFactory/ +[v6.5-master]: ${prefix}/${version}/fundamentals/promises/ -> ${base}/promises/ diff --git a/snooty.toml b/snooty.toml index b3d4d39e4..d98c29640 100644 --- a/snooty.toml +++ b/snooty.toml @@ -7,14 +7,17 @@ intersphinx = [ ] toc_landing_pages = [ - "/fundamentals/authentication", - "/fundamentals", - "/fundamentals/connection", - "/fundamentals/crud", - "/fundamentals/bson", - "/usage-examples", - "/quick-start", - "/aggregation-tutorials", + "/get-started", + "/connect", + "/aggregation", + "/security", + "/security/authentication", + "/data-formats", + "/connect/connection-options", + "/crud", + "/crud/update", + "/crud/transactions", + "/monitoring-and-logging" ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" diff --git a/source/aggregation-tutorials.txt b/source/aggregation-tutorials.txt deleted file mode 100644 index 8feb8eee9..000000000 --- a/source/aggregation-tutorials.txt +++ /dev/null @@ -1,123 +0,0 @@ -.. _node-aggregation-tutorials-landing: - -===================== -Aggregation Tutorials -===================== - -.. facet:: - :name: genre - :values: reference - -.. meta:: - :keywords: node.js, code example, runnable app - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -.. toctree:: - - Filtered Subset - Group & Total - Unpack Arrays & Group - One-to-One Join - Multi-Field Join - -Overview --------- - -Aggregation tutorials provide detailed explanations of common -aggregation tasks in a step-by-step format. The tutorials are adapted -from examples in the `Practical MongoDB Aggregations book -`__ by Paul Done. - -Each tutorial includes the following sections: - -- **Introduction**, which describes the purpose and common use cases of the - aggregation type. This section also describes the example and desired - outcome that the tutorial demonstrates. - -- **Before You Get Started**, which describes the necessary databases, - collections, and sample data that you must have before building the - aggregation pipeline and performing the aggregation. - -- **Tutorial**, which describes how to build and run the aggregation - pipeline. This section describes each stage of the completed - aggregation tutorial, and then explains how to run and interpret the - output of the aggregation. - -At the end of each aggregation tutorial, you can find a link to a fully -runnable Node.js code file that you can run in your environment. - -.. tip:: - - To learn more about performing aggregations, see the - :ref:`node-aggregation` guide. - -.. _node-agg-tutorial-template-app: - -Aggregation Template App ------------------------- - -Before you begin following an aggregation tutorial, you must set up a -new Node.js app. You can use this app to connect to a MongoDB -deployment, insert sample data into MongoDB, and run the aggregation -pipeline in each tutorial. - -.. tip:: - - To learn how to install the driver and connect to MongoDB, - see the :ref:`node-quick-start-download-and-install` and - :ref:`node-quick-start-create-deployment` steps of the - Quick Start guide. - -Once you install the driver, create a file called -``agg_tutorial.js``. Paste the following code in this file to create an -app template for the aggregation tutorials: - -.. literalinclude:: /includes/aggregation/template-app.js - :language: javascript - :copyable: true - -.. important:: - - In the preceding code, read the code comments to find the sections of - the code that you must modify for the tutorial you are following. - - If you attempt to run the code without making any changes, you will - encounter a connection error. - -For every tutorial, you must replace the connection string placeholder with -your deployment's connection string. - -.. tip:: - - To learn how to locate your deployment's connection string, see the - :ref:`node-quick-start-connection-string` step of the Quick Start guide. - -For example, if your connection string is -``"mongodb+srv://mongodb-example:27017"``, your connection string assignment resembles -the following: - -.. code-block:: javascript - :copyable: false - - const uri = "mongodb+srv://mongodb-example:27017"; - -To run the completed file after you modify the template for a -tutorial, run the following command in your shell: - -.. code-block:: bash - - node agg_tutorial.js - -Available Tutorials -------------------- - -- :ref:`node-aggregation-filtered-subset` -- :ref:`node-aggregation-group-total` -- :ref:`node-aggregation-arrays` -- :ref:`node-aggregation-one-to-one` -- :ref:`node-aggregation-multi-field` \ No newline at end of file diff --git a/source/fundamentals/aggregation.txt b/source/aggregation.txt similarity index 54% rename from source/fundamentals/aggregation.txt rename to source/aggregation.txt index 1ef5f1f7b..3912b8a8f 100644 --- a/source/fundamentals/aggregation.txt +++ b/source/aggregation.txt @@ -5,12 +5,24 @@ Aggregation =========== +.. meta:: + :description: Learn to use aggregation operations in the MongoDB Node.js Driver to create pipelines for data transformation and summarization. + :keywords: node.js, code example, runnable app + .. contents:: On this page :local: :backlinks: none :depth: 2 :class: singlecol +.. toctree:: + + Filtered Subset + Group & Total + Unpack Arrays & Group + One-to-One Join + Multi-Field Join + .. _nodejs-aggregation-overview: Overview @@ -98,7 +110,7 @@ database: .. tip:: - For more information on connecting to your MongoDB deployment, see the :doc:`Connection Guide `. + For more information on connecting to your MongoDB deployment, see the :doc:`Connection Guide `. Aggregation Example ~~~~~~~~~~~~~~~~~~~ @@ -131,6 +143,106 @@ This example produces the following output: For more information, see the `aggregate() API documentation <{+api+}/classes/Collection.html#aggregate>`__. +.. _node-aggregation-tutorials-landing: +.. _node-aggregation-tutorials: + +Aggregation Tutorials +--------------------- + +Aggregation tutorials provide detailed explanations of common +aggregation tasks in a step-by-step format. The tutorials are adapted +from examples in the `Practical MongoDB Aggregations book +`__ by Paul Done. + +Each tutorial includes the following sections: + +- **Introduction**, which describes the purpose and common use cases of the + aggregation type. This section also describes the example and desired + outcome that the tutorial demonstrates. + +- **Before You Get Started**, which describes the necessary databases, + collections, and sample data that you must have before building the + aggregation pipeline and performing the aggregation. + +- **Tutorial**, which describes how to build and run the aggregation + pipeline. This section describes each stage of the completed + aggregation tutorial, and then explains how to run and interpret the + output of the aggregation. + +At the end of each aggregation tutorial, you can find a link to a fully +runnable Node.js code file that you can run in your environment. + +.. tip:: + + To learn more about performing aggregations, see the + :ref:`node-aggregation` guide. + +.. _node-agg-tutorial-template-app: + +Aggregation Template App +~~~~~~~~~~~~~~~~~~~~~~~~ + +Before you begin following an aggregation tutorial, you must set up a +new Node.js app. You can use this app to connect to a MongoDB +deployment, insert sample data into MongoDB, and run the aggregation +pipeline in each tutorial. + +.. tip:: + + To learn how to install the driver and connect to MongoDB, + see the :ref:`node-get-started-download-and-install` and + :ref:`node-get-started-create-deployment` steps of the + Quick Start guide. + +Once you install the driver, create a file called +``agg_tutorial.js``. Paste the following code in this file to create an +app template for the aggregation tutorials: + +.. literalinclude:: /includes/aggregation/template-app.js + :language: javascript + :copyable: true + +.. important:: + + In the preceding code, read the code comments to find the sections of + the code that you must modify for the tutorial you are following. + + If you attempt to run the code without making any changes, you will + encounter a connection error. + +For every tutorial, you must replace the connection string placeholder with +your deployment's connection string. + +.. tip:: + + To learn how to locate your deployment's connection string, see the + :ref:`node-get-started-connection-string` step of the Quick Start guide. + +For example, if your connection string is +``"mongodb+srv://mongodb-example:27017"``, your connection string assignment resembles +the following: + +.. code-block:: javascript + :copyable: false + + const uri = "mongodb+srv://mongodb-example:27017"; + +To run the completed file after you modify the template for a +tutorial, run the following command in your shell: + +.. code-block:: bash + + node agg_tutorial.js + +Available Tutorials +~~~~~~~~~~~~~~~~~~~ + +- :ref:`node-aggregation-filtered-subset` +- :ref:`node-aggregation-group-total` +- :ref:`node-aggregation-arrays` +- :ref:`node-aggregation-one-to-one` +- :ref:`node-aggregation-multi-field` + Additional Examples ~~~~~~~~~~~~~~~~~~~ diff --git a/source/aggregation-tutorials/filtered-subset.txt b/source/aggregation/filtered-subset.txt similarity index 100% rename from source/aggregation-tutorials/filtered-subset.txt rename to source/aggregation/filtered-subset.txt diff --git a/source/aggregation-tutorials/group-total.txt b/source/aggregation/group-total.txt similarity index 100% rename from source/aggregation-tutorials/group-total.txt rename to source/aggregation/group-total.txt diff --git a/source/aggregation-tutorials/multi-field-join.txt b/source/aggregation/multi-field-join.txt similarity index 100% rename from source/aggregation-tutorials/multi-field-join.txt rename to source/aggregation/multi-field-join.txt diff --git a/source/aggregation-tutorials/one-to-one-join.txt b/source/aggregation/one-to-one-join.txt similarity index 100% rename from source/aggregation-tutorials/one-to-one-join.txt rename to source/aggregation/one-to-one-join.txt diff --git a/source/aggregation-tutorials/unpack-arrays.txt b/source/aggregation/unpack-arrays.txt similarity index 100% rename from source/aggregation-tutorials/unpack-arrays.txt rename to source/aggregation/unpack-arrays.txt diff --git a/source/atlas-search.txt b/source/atlas-search.txt new file mode 100644 index 000000000..4fac35792 --- /dev/null +++ b/source/atlas-search.txt @@ -0,0 +1,113 @@ +.. _node-atlas-search: + +========================= +Run an Atlas Search Query +========================= + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: full text, text analyzer, meta, pipeline, scoring, Lucene + :description: Learn about how to use Atlas Search in the {+driver-long+}. + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +Overview +-------- + +In this guide, you can learn how to use the {+driver-short+} to +run :atlas:`Atlas Search ` queries on a collection. +Atlas Search enables you to perform full-text searches on collections +hosted on MongoDB Atlas. Atlas Search indexes specify the behavior of the +search and which fields to index. + +Sample Data +~~~~~~~~~~~ + +The example in this guide uses the ``movies`` collection in the ``sample_mflix`` +database from the :atlas:`Atlas sample datasets `. To learn how to +create a free MongoDB Atlas cluster and load the sample datasets, see the +:atlas:`Get Started with Atlas ` guide. + +Run an Atlas Search Query +------------------------- + +This section shows how to create an aggregation pipeline to run an +Atlas Search query on a collection. In your array of pipeline stages, +add the ``$search`` stage to specify the search criteria. Then, call +the ``aggregate()`` method and pass your pipeline array as a parameter. + +.. tip:: + + To learn more about aggregation operations, see the :ref:`node-aggregation` + guide. + +Before running an Atlas Search query, you must create an Atlas Search index +on your collection. To learn how to programmatically create an Atlas Search +index, see the :ref:`node-indexes-search` section of the Indexes guide. + +Atlas Search Example +~~~~~~~~~~~~~~~~~~~~ + +This example runs an Atlas Search query by performing the +following actions: + +- Creates a ``$search`` stage that instructs the driver + to query for documents in which the ``title`` field contains + the word ``"Alabama"`` + +- Creates a ``$project`` stage that instructs the driver to + include the ``title`` field in the query results + +- Passes the pipeline stages to the ``aggregate()`` method and + prints the results + +.. io-code-block:: + :copyable: + + .. input:: /includes/atlas-search.js + :start-after: begin-atlas-search + :end-before: end-atlas-search + :language: java + :dedent: + + .. output:: + :language: console + :visible: false + + { + _id: new ObjectId('...'), + title: 'Alabama Moon' + } + { + _id: new ObjectId('...'), + title: 'Crazy in Alabama' + } + { + _id: new ObjectId('...'), + title: 'Sweet Home Alabama' + } + +.. tip:: Node.js Driver Atlas Search Examples + + To view more examples that use the {+driver-short+} to perform Atlas + Search queries, see :atlas:`Atlas Search Tutorials ` + in the Atlas documentation. + +Additional Information +---------------------- + +To learn more about Atlas Search, see :atlas:`Atlas Search ` +in the Atlas documentation. + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about the ``aggregate()`` method, see the +`API documentation <{+api+}/classes/Collection.html#aggregate>`__. diff --git a/source/atlas-vector-search.txt b/source/atlas-vector-search.txt new file mode 100644 index 000000000..9dd2124f7 --- /dev/null +++ b/source/atlas-vector-search.txt @@ -0,0 +1,177 @@ +.. _node-atlas-vector-search: + +================================ +Run an Atlas Vector Search Query +================================ + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: code example, semantic, nearest + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +Overview +-------- + +In this guide, you can learn how to use the Atlas Vector Search feature +in the {+driver-short+}. + +You can use {+vector-search+} to perform a vector search on your data stored in +Atlas. Vector search allows you to query your data based on semantic meaning +rather than just keyword matches, which helps you retrieve more relevant search +results. It enables your AI-powered applications to support use cases such as +semantic search, hybrid search, and generative search, including +Retrieval-Augmented Generation (RAG). + +To learn more about {+vector-search+}, see the :atlas:`{+vector-search+} +` guides in the MongoDB Atlas +documentation. + +.. important:: Feature Compatibility + + To learn what versions of MongoDB Atlas support this feature, see + :atlas:`Limitations ` + in the MongoDB Atlas documentation. + +Perform a Vector Search +----------------------- + +To use this feature, you must create a vector search index and index your +vector embeddings. To learn about how to programmatically create a +vector search index, see the :ref:`` section in the +Indexes guide. To learn more about vector embeddings, see +:atlas:`How to Create Vector Embeddings +` in the Atlas documentation. + +After you create a vector search index on your vector embeddings, you +can reference this index in your pipeline stage, as shown in the +following example. + +Sample Data +~~~~~~~~~~~ + +The example on this page shows how to build an aggregation pipeline that uses the +``$vectorSearch`` stage to perform a vector search on the +``sample_mflix.embedded_movies`` collection in the :atlas:`Atlas sample datasets +`. + +To learn how to create a free MongoDB Atlas cluster and load the sample datasets, see the +:atlas:`Get Started with Atlas ` guide. + +Vector Search Example +~~~~~~~~~~~~~~~~~~~~~ + +You can perform a vector search query by using the ``$vectorSearch`` stage +in an :ref:`aggregation pipeline `. To perform a vector +search on a collection, you must first have a collection with a field that contains +vector embeddings and a vector search index that covers that field. + +In the following example, the aggregation pipeline searches the ``plot`` field of each +document in the collection for text semantically related to the term "time travel". The +``queryVector`` field in the ``$vectorSearch`` pipeline is the vector representation of +your query. + +.. io-code-block:: + :copyable: true + + .. input:: /includes/atlas-vector-search-example.js + :language: javascript + :dedent: + + .. output:: + :language: javascript + :visible: false + + { + plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', + title: 'Thrill Seekers', + score: 0.9259490966796875 + } + { + plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', + title: 'About Time', + score: 0.9253997802734375 + } + { + plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', + title: 'Timecop', + score: 0.922332763671875 + } + { + plot: "After using his mother's newly built time machine, Dolf gets stuck + involuntary in the year 1212. He ends up in a children's crusade where he confronts + his new friends with modern techniques...", + title: 'Crusade in Jeans', + score: 0.92205810546875 + } + { + plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', + title: 'The Time Machine', + score: 0.921875 + } + { + plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', + title: 'A.P.E.X.', + score: 0.9202728271484375 + } + { + plot: "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", + title: 'Men in Black 3', + score: 0.9198150634765625 + } + { + plot: 'Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.', + title: 'Tomorrowland', + score: 0.91961669921875 + } + { + plot: 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.', + title: "The Time Traveler's Wife", + score: 0.9174346923828125 + } + { + plot: 'With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.', + title: 'Love Story 2050', + score: 0.9165191650390625 + } + +This query uses the ``$vectorSearch`` stage to: + +- Perform an Approximate Nearest Neighbor (ANN) vector search + +- Search for the specified term in the ``plot_embedding`` field + +- Set the number of nearest neighbors used in the search to 150 by using the + ``numCandidates`` option + +- Return a maximum of 10 documents from the query using the ``limit`` option + +It uses the ``$project`` stage to: + +- Only include the movie ``plot`` and ``title`` fields in the results + +- Add a ``score`` field to show the relevance of each result to the search term + +Additional Information +---------------------- + +To see more Atlas Vector Search tutorials for the {+driver-short+}, see the :atlas:`Atlas +Vector Search tutorials ` in the Atlas documentation. + +To learn more about the syntax of the ``$vectorSearch`` pipeline stage, +see the Syntax and Fields sections of the +:atlas:`Create and Run Queries ` +guide in the Atlas Vector Search section of the Atlas documentation. + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about the ``aggregate()`` method, see `aggregate() +<{+api+}/classes/Collection.html#aggregate>`__ in the API documentation. \ No newline at end of file diff --git a/source/fundamentals/connection.txt b/source/connect.txt similarity index 78% rename from source/fundamentals/connection.txt rename to source/connect.txt index c768dba01..6ca790ad7 100644 --- a/source/fundamentals/connection.txt +++ b/source/connect.txt @@ -1,8 +1,9 @@ .. _node-connection: +.. _node-connect: -========== -Connection -========== +================== +Connect to MongoDB +================== .. default-domain:: mongodb @@ -12,22 +13,19 @@ Connection .. meta:: :description: Learn how to configure your application's connection to a MongoDB deployment by using the Node.js driver. - :keywords: node.js + :keywords: client, ssl .. toctree:: - Connection Guide - Connection Options - Network Compression - TLS - SOCKS5 Proxy Support - Limit Server Execution Time + Connection Guide + Connection Options Connect with AWS Lambda + Connection Troubleshooting .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol Overview diff --git a/source/fundamentals/connection/connect.txt b/source/connect/connect.txt similarity index 100% rename from source/fundamentals/connection/connect.txt rename to source/connect/connect.txt diff --git a/source/fundamentals/connection/connection-options.txt b/source/connect/connection-options.txt similarity index 96% rename from source/fundamentals/connection/connection-options.txt rename to source/connect/connection-options.txt index 5958ed528..f41e50485 100644 --- a/source/fundamentals/connection/connection-options.txt +++ b/source/connect/connection-options.txt @@ -11,6 +11,14 @@ Connection Options .. meta:: :keywords: node.js, customize +.. toctree:: + :titlesonly: + :maxdepth: 1 + + Compress Network Traffic + Stable API + Limit Server Execution Time + This section explains the MongoDB connection and authentication options supported by the {+driver-short+} that you can set within a ``MongoClientOptions`` instance. @@ -42,8 +50,8 @@ string, see :manual:`Connection Strings ` in the - Specifies the authentication mechanism method to use for connection to the server. If you do not specify a value, the driver uses the default mechanism, either ``SCRAM-SHA-1`` or ``SCRAM-SHA-256`` depending on the server version. See - :ref:`authentication mechanism ` for available - authentication mechanisms. + the :ref:`Authentication Mechanisms ` section + for available authentication mechanisms. * - **authMechanismProperties** - comma separated key:value pairs, for example, "opt1:val1,opt2:val2" diff --git a/source/fundamentals/connection/csot.txt b/source/connect/connection-options/csot.txt similarity index 100% rename from source/fundamentals/connection/csot.txt rename to source/connect/connection-options/csot.txt diff --git a/source/fundamentals/connection/network-compression.txt b/source/connect/connection-options/network-compression.txt similarity index 100% rename from source/fundamentals/connection/network-compression.txt rename to source/connect/connection-options/network-compression.txt diff --git a/source/fundamentals/stable-api.txt b/source/connect/connection-options/stable-api.txt similarity index 100% rename from source/fundamentals/stable-api.txt rename to source/connect/connection-options/stable-api.txt diff --git a/source/connection-troubleshooting.txt b/source/connect/connection-troubleshooting.txt similarity index 99% rename from source/connection-troubleshooting.txt rename to source/connect/connection-troubleshooting.txt index 04f10c5c6..33480cdc5 100644 --- a/source/connection-troubleshooting.txt +++ b/source/connect/connection-troubleshooting.txt @@ -176,7 +176,7 @@ issues when attempting to connect to MongoDB using ``SCRAM-SHA-256``. .. tip:: For more information about connection strings, - see :ref:`Connection URI ` in the Connection Guide. + see :ref:`Connection URI ` section in the Connection Guide. If your connection string contains a username and password, ensure that they are in the correct format. If the username or password includes any of the diff --git a/source/crud.txt b/source/crud.txt new file mode 100644 index 000000000..2a39279d5 --- /dev/null +++ b/source/crud.txt @@ -0,0 +1,44 @@ +.. _node-crud-landing: +.. _node-crud-operations: + +=============== +CRUD Operations +=============== + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :description: Learn how to perform create, read, update, and delete (CRUD) operations to work with the data stored in MongoDB by using the Node.js driver. + :keywords: node.js + +.. toctree:: + :caption: CRUD Operations + + Insert Documents + Query Documents + Update Documents + Delete Documents + Bulk Write Operations + Compound Operations + Transactions + Generate Custom _id Values + Store Large Files + Operations on Replica Sets + Collations + +CRUD (Create, Read, Update, Delete) operations enable you to work with +data stored in MongoDB. + +- :ref:`node-insert` +- :ref:`node-query` +- :ref:`node-update` +- :ref:`node-delete` +- :ref:`node-bulk-write` +- :ref:`node-crud-compound-operations` +- :ref:`node-transactions` +- :ref:`node-pkfactory` +- :ref:`node-gridfs` +- :ref:`node-crud-write-read-pref` +- :ref:`node-fundamentals-collations` diff --git a/source/fundamentals/crud/write-operations/bulk.txt b/source/crud/bulk-write.txt similarity index 99% rename from source/fundamentals/crud/write-operations/bulk.txt rename to source/crud/bulk-write.txt index 7cba6ee8a..ec8280f1c 100644 --- a/source/fundamentals/crud/write-operations/bulk.txt +++ b/source/crud/bulk-write.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-bulk: +.. _node-bulk-write: =============== Bulk Operations diff --git a/source/fundamentals/collations.txt b/source/crud/collations.txt similarity index 100% rename from source/fundamentals/collations.txt rename to source/crud/collations.txt diff --git a/source/fundamentals/crud/compound-operations.txt b/source/crud/compound-operations.txt similarity index 100% rename from source/fundamentals/crud/compound-operations.txt rename to source/crud/compound-operations.txt diff --git a/source/fundamentals/crud/write-operations/delete.txt b/source/crud/delete.txt similarity index 99% rename from source/fundamentals/crud/write-operations/delete.txt rename to source/crud/delete.txt index f17db955f..c476a0eab 100644 --- a/source/fundamentals/crud/write-operations/delete.txt +++ b/source/crud/delete.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-delete: +.. _node-delete: ================ Delete Documents diff --git a/source/fundamentals/gridfs.txt b/source/crud/gridfs.txt similarity index 98% rename from source/fundamentals/gridfs.txt rename to source/crud/gridfs.txt index 1b0f9db64..4175bbacf 100644 --- a/source/fundamentals/gridfs.txt +++ b/source/crud/gridfs.txt @@ -1,8 +1,8 @@ .. _node-gridfs: -====== -GridFS -====== +============================= +Store Large Files with GridFS +============================= .. facet:: :name: genre @@ -166,8 +166,8 @@ see the following resources: - `find() API documentation <{+api+}/classes/GridFSBucket.html#find>`__ - `FindCursor API documentation <{+api+}/classes/FindCursor.html>`__ -- :doc:`Cursor Fundamentals page ` -- :doc:`Read Operations page ` +- :ref:`Access Data From a Cursor guide ` +- :ref:`Find Documents guide ` .. _gridfs-download-files: diff --git a/source/fundamentals/crud/write-operations/insert.txt b/source/crud/insert.txt similarity index 98% rename from source/fundamentals/crud/write-operations/insert.txt rename to source/crud/insert.txt index 91458c85a..c8a2d0951 100644 --- a/source/fundamentals/crud/write-operations/insert.txt +++ b/source/crud/insert.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-insert-data: +.. _node-insert: ================ Insert Documents @@ -44,8 +45,8 @@ operations: full-screen button (:guilabel:`⛶`) in the top-right corner of the lab pane. The following sections focus on ``insertOne()`` and ``insertMany()``. For an -example on how to use the ``bulkWrite()`` method, see our runnable :doc:`Bulk -Operations Example `. +example on how to use the ``bulkWrite()`` method, see the :ref:`node-usage-bulk` +section of the :ref:`node-bulk-write` guide. .. _id-note: diff --git a/source/fundamentals/crud/write-operations/pkFactory.txt b/source/crud/pkFactory.txt similarity index 96% rename from source/fundamentals/crud/write-operations/pkFactory.txt rename to source/crud/pkFactory.txt index 504c91f67..68f53940a 100644 --- a/source/fundamentals/crud/write-operations/pkFactory.txt +++ b/source/crud/pkFactory.txt @@ -1,8 +1,8 @@ .. _node-pkfactory: -================================== -Generate Custom Values for ``_id`` -================================== +=============================== +Generate Custom Values for _id +=============================== .. default-domain:: mongodb diff --git a/source/fundamentals/crud/query-document.txt b/source/crud/query-document.txt similarity index 99% rename from source/fundamentals/crud/query-document.txt rename to source/crud/query-document.txt index 1e13e0f70..e01bee4a7 100644 --- a/source/fundamentals/crud/query-document.txt +++ b/source/crud/query-document.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-query-document: +.. _node-query-document: =============== Specify a Query @@ -9,7 +10,7 @@ Specify a Query .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol Overview diff --git a/source/crud/query.txt b/source/crud/query.txt new file mode 100644 index 000000000..d51c8e410 --- /dev/null +++ b/source/crud/query.txt @@ -0,0 +1,41 @@ +.. _node-read-operations: +.. _node-query: + +================ +Query Operations +================ + +.. meta:: + :description: Learn about the commands for running MongoDB read operations by using the {+driver-long+}. + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: code example, node.js, sample dataset + +.. toctree:: + :caption: Query Operations + + Find Documents + Sort Results + Skip Returned Results + Limit Returned Results + Specify Fields to Return + Count Documents + Distinct Field Values + Search Text + Access Data from a Cursor + Geospatial Queries + +- :doc:`/crud/query/retrieve` +- :doc:`/crud/query/distinct` +- :doc:`/crud/query/sort` +- :doc:`/crud/query/skip` +- :doc:`/crud/query/limit` +- :doc:`/crud/query/project` +- :doc:`/crud/query/count` +- :doc:`/crud/query/text` +- :doc:`/crud/query/cursor` +- :doc:`/crud/query/geo` diff --git a/source/usage-examples/count.txt b/source/crud/query/count.txt similarity index 97% rename from source/usage-examples/count.txt rename to source/crud/query/count.txt index fa4f2c3b4..815a6dd06 100644 --- a/source/usage-examples/count.txt +++ b/source/crud/query/count.txt @@ -1,4 +1,5 @@ .. _node-usage-count: +.. _node-count: =============== Count Documents @@ -23,7 +24,7 @@ provides an **accurate** count of the number of documents and supports specifying a filter. Choose the appropriate method for your workload. To specify which documents you wish to count, ``countDocuments()`` -accepts a :doc:`query ` parameter. +accepts a :ref:`query ` parameter. ``countDocuments()`` counts the documents that match the specified query. ``countDocuments()`` and ``estimatedDocumentCount()`` support optional diff --git a/source/fundamentals/crud/read-operations/cursor.txt b/source/crud/query/cursor.txt similarity index 96% rename from source/fundamentals/crud/read-operations/cursor.txt rename to source/crud/query/cursor.txt index a4aa46d79..be297a9b8 100644 --- a/source/fundamentals/crud/read-operations/cursor.txt +++ b/source/crud/query/cursor.txt @@ -1,4 +1,5 @@ .. _node-access-cursor: +.. _node-cursor: ========================= Access Data From a Cursor @@ -36,8 +37,8 @@ The following functions directly return cursors: - ``Db.listCollections()`` -Other methods such as :doc:`Collection.findOne() ` -and :doc:`Collection.watch() ` use +Other methods such as :ref:`Collection.findOne() ` +and :doc:`Collection.watch() ` use cursors internally, and return the results of the operations instead of a cursor. diff --git a/source/fundamentals/crud/read-operations/distinct.txt b/source/crud/query/distinct.txt similarity index 99% rename from source/fundamentals/crud/read-operations/distinct.txt rename to source/crud/query/distinct.txt index 6280fdb4d..96aa5ca06 100644 --- a/source/fundamentals/crud/read-operations/distinct.txt +++ b/source/crud/query/distinct.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-distinct: +.. _node-distinct: ======================== Retrieve Distinct Values diff --git a/source/fundamentals/crud/read-operations/geo.txt b/source/crud/query/geo.txt similarity index 96% rename from source/fundamentals/crud/read-operations/geo.txt rename to source/crud/query/geo.txt index 2a17b7b55..582425b71 100644 --- a/source/fundamentals/crud/read-operations/geo.txt +++ b/source/crud/query/geo.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-geospatial: +.. _node-geospatial: =================== Search Geospatially @@ -106,8 +107,9 @@ for more information. Examples -------- -The following examples use the MongoDB Atlas sample dataset. You can learn how to set up your own free-tier Atlas cluster and how to load the sample dataset in our -:doc:`quick start guide `. +The following examples use the MongoDB Atlas sample dataset. You can learn how +to set up your own free-tier Atlas cluster and how to load the sample dataset in our +:doc:`Get Started ` guide. The examples use the ``theaters`` collection in the ``sample_mflix`` database from the sample dataset. The ``theaters`` collection contains a ``2dsphere`` index diff --git a/source/fundamentals/crud/read-operations/limit.txt b/source/crud/query/limit.txt similarity index 100% rename from source/fundamentals/crud/read-operations/limit.txt rename to source/crud/query/limit.txt diff --git a/source/fundamentals/crud/read-operations/project.txt b/source/crud/query/project.txt similarity index 99% rename from source/fundamentals/crud/read-operations/project.txt rename to source/crud/query/project.txt index d1757b8a5..ee48d5d52 100644 --- a/source/fundamentals/crud/read-operations/project.txt +++ b/source/crud/query/project.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-project: +.. _node-project: ============================== Specify Which Fields to Return diff --git a/source/fundamentals/crud/read-operations/retrieve.txt b/source/crud/query/retrieve.txt similarity index 97% rename from source/fundamentals/crud/read-operations/retrieve.txt rename to source/crud/query/retrieve.txt index 59cfcf8c6..2e9d9466a 100644 --- a/source/fundamentals/crud/read-operations/retrieve.txt +++ b/source/crud/query/retrieve.txt @@ -1,8 +1,9 @@ .. _node-fundamentals-retrieve-data: +.. _node-find: -============= -Retrieve Data -============= +============== +Find Documents +============== .. facet:: :name: genre @@ -15,7 +16,7 @@ Retrieve Data .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol .. _nodejs-driver-retrieve-data-overview: @@ -233,8 +234,8 @@ data whenever write operations are executed on the collection. Additional Information ~~~~~~~~~~~~~~~~~~~~~~ -For a runnable example of the ``watch()`` method, see the -:ref:`Watch for Changes ` usage example. +For a runnable example of the ``watch()`` method, see the :ref:`examples +` section in the :ref:`node-change-streams` guide. .. _node-retrieve-instruqt-lab: diff --git a/source/fundamentals/crud/read-operations/skip.txt b/source/crud/query/skip.txt similarity index 100% rename from source/fundamentals/crud/read-operations/skip.txt rename to source/crud/query/skip.txt diff --git a/source/fundamentals/crud/read-operations/sort.txt b/source/crud/query/sort.txt similarity index 100% rename from source/fundamentals/crud/read-operations/sort.txt rename to source/crud/query/sort.txt diff --git a/source/fundamentals/crud/read-operations/text.txt b/source/crud/query/text.txt similarity index 99% rename from source/fundamentals/crud/read-operations/text.txt rename to source/crud/query/text.txt index ba70480bb..b06034efc 100644 --- a/source/fundamentals/crud/read-operations/text.txt +++ b/source/crud/query/text.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-text: +.. _node-search-text: =========== Search Text diff --git a/source/fundamentals/crud/read-write-pref.txt b/source/crud/read-write-pref.txt similarity index 100% rename from source/fundamentals/crud/read-write-pref.txt rename to source/crud/read-write-pref.txt diff --git a/source/fundamentals/transactions.txt b/source/crud/transactions.txt similarity index 98% rename from source/fundamentals/transactions.txt rename to source/crud/transactions.txt index a2674023d..9ce443bff 100644 --- a/source/fundamentals/transactions.txt +++ b/source/crud/transactions.txt @@ -1,4 +1,5 @@ .. _nodejs-transactions: +.. _node-transactions: ============ Transactions @@ -17,6 +18,12 @@ Transactions :depth: 2 :class: singlecol +.. toctree:: + :caption: Transaction Usage Examples + + Convenient Transaction API + Core API + Overview -------- diff --git a/source/usage-examples/transaction-conv.txt b/source/crud/transactions/transaction-conv.txt similarity index 100% rename from source/usage-examples/transaction-conv.txt rename to source/crud/transactions/transaction-conv.txt diff --git a/source/usage-examples/transaction-core.txt b/source/crud/transactions/transaction-core.txt similarity index 100% rename from source/usage-examples/transaction-core.txt rename to source/crud/transactions/transaction-core.txt diff --git a/source/fundamentals/crud/write-operations/upsert.txt b/source/crud/update.txt similarity index 87% rename from source/fundamentals/crud/write-operations/upsert.txt rename to source/crud/update.txt index bab72e7b9..496167bb8 100644 --- a/source/fundamentals/crud/write-operations/upsert.txt +++ b/source/crud/update.txt @@ -1,8 +1,9 @@ .. _node-fundamentals-upsert: +.. _node-update: -====================================== -Insert or Update in a Single Operation -====================================== +================ +Update Documents +================ .. facet:: :name: genre @@ -14,9 +15,17 @@ Insert or Update in a Single Operation .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol +.. toctree:: + :titlesonly: + :maxdepth: 2 + + Modify Documents + Replace + Update Arrays + Overview -------- @@ -26,9 +35,9 @@ an insert or update operation depends on whether the document exists. In these cases, you can streamline your application logic by using the ``upsert`` option available in the following methods: -- :doc:`updateOne() ` -- :doc:`replaceOne() ` -- :doc:`updateMany() ` +- :ref:`updateOne() ` +- :ref:`replaceOne() ` +- :ref:`updateMany() ` If the query filter passed to these methods does not find any matches and you set the ``upsert`` option to ``true``, MongoDB inserts the update @@ -69,6 +78,8 @@ If a food truck named "Deli Llama" exists, the method call above updates the document in the collection. However, if there are no food trucks named "Deli Llama" in your collection, no changes are made. +.. _node-upsert: + Performing an Upsert -------------------- diff --git a/source/fundamentals/crud/write-operations/embedded-arrays.txt b/source/crud/update/embedded-arrays.txt similarity index 99% rename from source/fundamentals/crud/write-operations/embedded-arrays.txt rename to source/crud/update/embedded-arrays.txt index e7672312f..679779590 100644 --- a/source/fundamentals/crud/write-operations/embedded-arrays.txt +++ b/source/crud/update/embedded-arrays.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-update-array: +.. _node-update-arrays: =========================== Update Arrays in a Document diff --git a/source/fundamentals/crud/write-operations/modify.txt b/source/crud/update/modify.txt similarity index 95% rename from source/fundamentals/crud/write-operations/modify.txt rename to source/crud/update/modify.txt index 5c841b28a..3b42230b7 100644 --- a/source/fundamentals/crud/write-operations/modify.txt +++ b/source/crud/update/modify.txt @@ -1,4 +1,5 @@ .. _node-fundamentals-change-a-document: +.. _node-modify: ================ Modify Documents @@ -7,7 +8,7 @@ Modify Documents .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol Overview @@ -130,11 +131,10 @@ the ``quantity`` field and all other values unchanged: quantity: 5, } -If an update operation fails to match any documents in a collection, it -does not make any changes. Update operations can be configured to perform -an :doc:`upsert ` which -attempts to perform an update, but if no documents are matched, inserts -a new document with the specified fields and values. +If an update operation fails to match any documents in a collection, it does not +make any changes. Update operations can be configured to perform an :doc:`upsert +` which attempts to perform an update, but if no documents are +matched, inserts a new document with the specified fields and values. You cannot modify the ``_id`` field of a document nor change a field to a value that violates a unique index constraint. See the {+mdb-server+} manual diff --git a/source/usage-examples/replaceOne.txt b/source/crud/update/replace.txt similarity index 99% rename from source/usage-examples/replaceOne.txt rename to source/crud/update/replace.txt index a0fb6d4b4..559bd1fe6 100644 --- a/source/usage-examples/replaceOne.txt +++ b/source/crud/update/replace.txt @@ -1,4 +1,5 @@ .. _node-usage-replaceone: +.. _node-replace: ================== Replace a Document diff --git a/source/fundamentals/crud/write-operations.txt b/source/crud/write-operations.txt similarity index 100% rename from source/fundamentals/crud/write-operations.txt rename to source/crud/write-operations.txt diff --git a/source/data-formats.txt b/source/data-formats.txt new file mode 100644 index 000000000..1782c9208 --- /dev/null +++ b/source/data-formats.txt @@ -0,0 +1,35 @@ +.. _node-data-formats: + +======================== +Specialized Data Formats +======================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: bson, uuid, date, time + +.. toctree:: + :titlesonly: + :maxdepth: 1 + + BSON Settings + Time Series Data + +Overview +-------- + +You can use several types of specialized data formats in your {+driver-short+} +application. To learn how to work with these data formats, see the following +sections: + +- Learn how to work with BSON documents in the :ref:`node-bson-control` guide +- Learn how to work with time series data in the :ref:`node-time-series` guide diff --git a/source/fundamentals/bson.txt b/source/data-formats/bson.txt similarity index 97% rename from source/fundamentals/bson.txt rename to source/data-formats/bson.txt index 9d1b77b54..627c90e96 100644 --- a/source/fundamentals/bson.txt +++ b/source/data-formats/bson.txt @@ -1,4 +1,5 @@ .. _node-bson-control: +.. _node-bson: ============= BSON Settings diff --git a/source/fundamentals/bson/undefined-values.txt b/source/data-formats/bson/undefined-values.txt similarity index 100% rename from source/fundamentals/bson/undefined-values.txt rename to source/data-formats/bson/undefined-values.txt diff --git a/source/fundamentals/bson/utf8-validation.txt b/source/data-formats/bson/utf8-validation.txt similarity index 100% rename from source/fundamentals/bson/utf8-validation.txt rename to source/data-formats/bson/utf8-validation.txt diff --git a/source/fundamentals/time-series.txt b/source/data-formats/time-series.txt similarity index 95% rename from source/fundamentals/time-series.txt rename to source/data-formats/time-series.txt index 49b31da51..04c399410 100644 --- a/source/fundamentals/time-series.txt +++ b/source/data-formats/time-series.txt @@ -1,3 +1,5 @@ +.. _node-time-series: + =========== Time Series =========== @@ -36,7 +38,7 @@ querying time series data. For more information on querying data in the MongoDB Node.js driver, see the following resources: -- :ref:`Guide On Read Operations ` +- :ref:`Guide On Read Operations ` - :ref:`Guide On Aggregation ` .. note:: Window Functions diff --git a/source/fundamentals.txt b/source/fundamentals.txt deleted file mode 100644 index e307628cf..000000000 --- a/source/fundamentals.txt +++ /dev/null @@ -1,27 +0,0 @@ -============ -Fundamentals -============ - -.. default-domain:: mongodb - -.. toctree:: - - Connection - Stable API - Authentication - CRUD Operations - Promises - Aggregation - Transactions - Run a Command - Indexes - Collations - Logging - Monitoring - GridFS - Time Series - TypeScript - BSON Settings - In-Use Encryption - -.. include:: /includes/fundamentals-sections.rst diff --git a/source/fundamentals/crud.txt b/source/fundamentals/crud.txt deleted file mode 100644 index daa80f8aa..000000000 --- a/source/fundamentals/crud.txt +++ /dev/null @@ -1,57 +0,0 @@ -.. _node-crud-landing: - -=============== -CRUD Operations -=============== - -.. facet:: - :name: genre - :values: reference - -.. meta:: - :description: Learn how to perform create, read, update, and delete (CRUD) operations to work with the data stored in MongoDB by using the Node.js driver. - :keywords: node.js - -.. toctree:: - :caption: CRUD Operations - - Read - Write - Query - Compound Operations - Operations on Replica Sets - -CRUD (Create, Read, Update, Delete) operations allow you to work with -the data stored in MongoDB. - -The CRUD operation documentation is categorized in two sections: - -- :doc:`Read Operations ` find and return - documents stored within your MongoDB database. -- :doc:`Write Operations ` insert, modify, - or delete documents in your MongoDB database. - -Some operations combine aspects of read and write operations. See our -guide on :doc:`compound operations ` -to learn more about these hybrid methods. - -Compatibility -------------- - -.. |page-topic| replace:: perform CRUD operations -.. |link-topic-ing| replace:: performing CRUD operations in the Atlas UI - -.. |atlas-url| replace:: :atlas:`Create, View, Update, and Delete Documents ` - -.. include:: /includes/fact-atlas-compatible.rst -.. include:: /includes/fact-atlas-link.rst - -.. note:: - - To learn more about performing CRUD operations, see the following posts on the `MongoDB - Developer Hub `__: - - - Learn how to apply `CRUD Operations `__ - with an example scenario. - - Analyze data in MongoDB Atlas using the `Aggregation Pipeline `__. - diff --git a/source/fundamentals/crud/read-operations.txt b/source/fundamentals/crud/read-operations.txt deleted file mode 100644 index 749c06a20..000000000 --- a/source/fundamentals/crud/read-operations.txt +++ /dev/null @@ -1,38 +0,0 @@ -.. _node-read-operations: - -=============== -Read Operations -=============== - -.. meta:: - :description: Learn about the commands for running MongoDB read operations by using the {+driver-long+}. - -.. facet:: - :name: genre - :values: reference - -.. meta:: - :keywords: code example, node.js, sample dataset - -.. toctree:: - :caption: Read Operations - - Retrieve Data - Access Data from a Cursor - Distinct Values - Sort Results - Skip Returned Results - Limit Returned Results - Specify Fields to Return - Search Geospatially - Search Text - -- :doc:`/fundamentals/crud/read-operations/retrieve` -- :doc:`/fundamentals/crud/read-operations/cursor` -- :doc:`/fundamentals/crud/read-operations/distinct` -- :doc:`/fundamentals/crud/read-operations/sort` -- :doc:`/fundamentals/crud/read-operations/skip` -- :doc:`/fundamentals/crud/read-operations/limit` -- :doc:`/fundamentals/crud/read-operations/project` -- :doc:`/fundamentals/crud/read-operations/geo` -- :doc:`/fundamentals/crud/read-operations/text` diff --git a/source/fundamentals/monitoring.txt b/source/fundamentals/monitoring.txt deleted file mode 100644 index dde3dd3be..000000000 --- a/source/fundamentals/monitoring.txt +++ /dev/null @@ -1,21 +0,0 @@ -========== -Monitoring -========== - -.. facet:: - :name: genre - :values: reference - -.. toctree:: - :caption: CRUD Operations - - Clusters - Commands - Connection Pool - -- :doc:`Cluster Monitoring `: monitoring - changes in a cluster -- :doc:`Command Monitoring `: monitoring - the execution status of commands -- :doc:`Connection Pool Monitoring `: monitoring - the driver's connection pool \ No newline at end of file diff --git a/source/get-started.txt b/source/get-started.txt new file mode 100644 index 000000000..43185ccc7 --- /dev/null +++ b/source/get-started.txt @@ -0,0 +1,272 @@ +.. _node-get-started: + +=================================== +Get Started with the Node.js Driver +=================================== + +.. facet:: + :name: genre + :values: tutorial + +.. meta:: + :description: Learn how to create an app to connect to MongoDB deployment by using the Node.js driver. + :keywords: node.js + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Overview +-------- + +This guide shows you how to create an application that uses the +{+driver-long+} to connect to a MongoDB cluster hosted on MongoDB Atlas. +The {+driver-short+} is a library of functions that you can use to connect +to and communicate with MongoDB. + +.. tip:: + + MongoDB Atlas is a fully managed cloud database service that hosts your + MongoDB deployments. You can create your own free (no credit card + required) MongoDB Atlas deployment by following the steps in this guide. + +Follow the steps in this guide to connect a sample Node.js application to +a MongoDB Atlas deployment. If you prefer to connect to MongoDB using a different +driver or programming language, see our :driver:`list of official drivers <>`. + +.. _node-quick-start-download-and-install: +.. _node-get-started-download-and-install: + +Download and Install +-------------------- + +.. procedure:: + :style: connected + + .. step:: Install dependencies + + Ensure you have the following dependencies installed in + your development environment: + + - Node.js {+min-node-version+} or later + - npm (Node Package Manager) + + To learn how to install Node.js and npm, see + `Downloading and installing Node.js and npm `__ + in the npm documentation. + + .. step:: Create a project directory + + In your shell, run the following command to create a + directory called ``node_quickstart`` for this project: + + .. code-block:: bash + + mkdir node_quickstart + + Then, run the following commands to navigate into the + directory and initialize your Node.js project: + + .. code-block:: bash + + cd node_quickstart + npm init -y + + When the initialization command successfully completes, you have a ``package.json`` + file in your ``node_quickstart`` directory. + + .. step:: Install the Node.js Driver + + Run the following command from your project directory to install + the driver: + + .. code-block:: bash + + npm install mongodb@{+version+} + + This command performs the following actions: + + - Downloads the ``mongodb`` package and the dependencies it requires + - Saves the package in the ``node_modules`` directory + - Records the dependency information in the ``package.json`` file + +After you complete these steps, you have a new project directory with +the driver dependencies installed. + +.. _node-quick-start-create-deployment: +.. _node-get-started-create-deployment: + +Create a MongoDB Deployment +--------------------------- + +You can create a free tier MongoDB deployment on MongoDB Atlas +to store and manage your data. MongoDB Atlas hosts and manages +your MongoDB database in the cloud. + +.. procedure:: + :style: connected + + .. step:: Create a free MongoDB deployment on Atlas + + Complete the :atlas:`Get Started with Atlas ` + guide to set up a new Atlas account and load sample data into a new free + tier MongoDB deployment. + + .. step:: Save your credentials + + After you create your database user, save that user's + username and password to a safe location for use in an upcoming step. + +After you complete these steps, you have a new free tier MongoDB +deployment on Atlas, database user credentials, and sample data loaded +in your database. + +.. _node-quick-start-connection-string: +.. _node-get-started-connection-string: + +Create a Connection String +-------------------------- + +You can connect to your MongoDB deployment by providing a +**connection URI**, also called a *connection string*, which +instructs the driver on how to connect to a MongoDB deployment +and how to behave while connected. + +The connection string includes the hostname or IP address and +port of your deployment, the authentication mechanism, user credentials +when applicable, and connection options. + +.. procedure:: + :style: connected + + .. step:: Find your MongoDB Atlas connection string + + To retrieve your connection string for the deployment that + you created in the :ref:`previous section `, + log into your Atlas account and navigate to the + :guilabel:`Clusters` section and click the :guilabel:`Connect` button + for your new deployment. + + .. figure:: /includes/figures/atlas_connection_connect_cluster.png + :alt: The connect button in the clusters section of the Atlas UI + + .. step:: Copy your connection string + + Click the button on the right of the connection string to copy it to + your clipboard, as shown in the following screenshot: + + .. figure:: /includes/figures/atlas_connection_copy_uri_node.png + :alt: The connection string copy button in the Atlas UI + + .. step:: Update the placeholders + + Paste your connection string into a file in your preferred text editor + and replace the ``username`` and ```` placeholders with your + database user's username and password. + + Save this file to a safe location for use in the next section. + +After completing these steps, you have a connection string that +contains your database username and password. + +.. _node-quick-start-connect-to-mongodb: +.. _node-get-started-connect-to-mongodb: + +Connect to MongoDB +------------------ + +.. procedure:: + :style: connected + + .. step:: Create your Node.js application + + In your ``node_quickstart`` directory, create a file called + ``index.js`` for your application. + + Copy and paste the following code into the ``index.js`` file: + + .. code-block:: js + + const { MongoClient } = require("mongodb"); + + // Replace the uri string with your connection string + const uri = ""; + + const client = new MongoClient(uri); + + async function run() { + try { + const database = client.db('sample_mflix'); + const movies = database.collection('movies'); + + // Queries for a movie that has a title value of 'Back to the Future' + const query = { title: 'Back to the Future' }; + const movie = await movies.findOne(query); + + console.log(movie); + } finally { + await client.close(); + } + } + run().catch(console.dir); + + .. step:: Assign the connection string + + Replace the ```` placeholder with the + connection string that you copied from the :ref:`node-quick-start-connection-string` + step of this guide. + + .. step:: Run your Node.js application + + From your project directory, run the following command to start + the application: + + .. code-block:: none + + node index.js + + The output includes details about the retrieved movie document: + + .. code-block:: none + + { + _id: ..., + plot: 'A young man is accidentally sent 30 years into the past...', + genres: [ 'Adventure', 'Comedy', 'Sci-Fi' ], + ... + title: 'Back to the Future', + ... + } + + If you encounter an error or see no output, verify that you specified the + proper connection string in the ``index.js`` file and that you loaded the + sample data. + +After you complete these steps, you have a working application that +uses the driver to connect to your MongoDB deployment, query +the sample data, and print out the result. + +.. _node-quick-start-next-steps: +.. _node-get-started-next-steps: + +Next Steps +---------- + +Congratulations on completing the quick start tutorial! + +.. include:: /includes/quick-start/troubleshoot.rst + +In this tutorial, you created a Node.js application that +connects to a MongoDB deployment hosted on MongoDB Atlas +and retrieves a document that matches a query. + +Learn more about the {+driver-short+} from the following resources: + +- Discover how to configure your MongoDB connection in the + :ref:`Connect to MongoDB ` section. + +- Discover how to perform read and write operations in the + :ref:`CRUD Operations ` section. + \ No newline at end of file diff --git a/source/includes/atlas-search.js b/source/includes/atlas-search.js new file mode 100644 index 000000000..49e679331 --- /dev/null +++ b/source/includes/atlas-search.js @@ -0,0 +1,41 @@ +const { MongoClient } = require("mongodb"); + +// Replace the placeholder with your connection string. +const uri = ""; +const client = new MongoClient(uri); + +async function run() { + try { + const database = client.db("sample_mflix"); + const collection = database.collection("movies"); + + // Queries for documents that have a "title" value containing the word "Alabama" + // begin-atlas-search + const pipeline = [ + { + $search: { + index: "default", // Replace with your search index name + text: { + query: "Alabama", + path: "title" + } + } + }, + { + $project: { + title: 1 + } + } + ]; + + const cursor = collection.aggregate(pipeline); + for await (const document of cursor) { + console.log(document); + } + // end-atlas-search + } finally { + await client.close(); + } +} + +run().catch(console.dir); \ No newline at end of file diff --git a/source/includes/atlas-vector-search-example.js b/source/includes/atlas-vector-search-example.js new file mode 100644 index 000000000..044660f25 --- /dev/null +++ b/source/includes/atlas-vector-search-example.js @@ -0,0 +1,50 @@ +const { MongoClient } = require("mongodb"); + +// Replace with the connection string to your Atlas cluster to connect +const uri = ""; + +const client = new MongoClient(uri); + +async function run() { + try { + await client.connect(); + + // Sets the namespace + const database = client.db("sample_mflix"); + const coll = database.collection("embedded_movies"); + + // Defines the pipeline + const agg = [ + { + '$vectorSearch': { + 'index': 'vector_index', + 'path': 'plot_embedding', + 'queryVector': Binary.fromFloat32Array(Float32Array.from([ + -0.0016261312, -0.028070757, -0.011342932, -0.012775794, -0.0027440966, 0.008683807, -0.02575152, -0.02020668, -0.010283281, -0.0041719596, 0.021392956, 0.028657231, -0.006634482, 0.007490867, 0.018593878, 0.0038187427, 0.029590257, -0.01451522, 0.016061379, 0.00008528442, -0.008943722, 0.01627464, 0.024311995, -0.025911469, 0.00022596726, -0.008863748, 0.008823762, -0.034921836, 0.007910728, -0.01515501, 0.035801545, -0.0035688248, -0.020299982, -0.03145631, -0.032256044, -0.028763862, -0.0071576433, -0.012769129, 0.012322609, -0.006621153, 0.010583182, 0.024085402, -0.001623632, 0.007864078, -0.021406285, 0.002554159, 0.012229307, -0.011762793, 0.0051682983, 0.0048484034, 0.018087378, 0.024325324, -0.037694257, -0.026537929, -0.008803768, -0.017767483, -0.012642504, -0.0062712682, 0.0009771782, -0.010409906, 0.017754154, -0.004671795, -0.030469967, 0.008477209, -0.005218282, -0.0058480743, -0.020153364, -0.0032805866, 0.004248601, 0.0051449724, 0.006791097, 0.007650814, 0.003458861, -0.0031223053, -0.01932697, -0.033615597, 0.00745088, 0.006321252, -0.0038154104, 0.014555207, 0.027697546, -0.02828402, 0.0066711367, 0.0077107945, 0.01794076, 0.011349596, -0.0052715978, 0.014755142, -0.019753495, -0.011156326, 0.011202978, 0.022126047, 0.00846388, 0.030549942, -0.0041386373, 0.018847128, -0.00033655585, 0.024925126, -0.003555496, -0.019300312, 0.010749794, 0.0075308536, -0.018287312, -0.016567878, -0.012869096, -0.015528221, 0.0078107617, -0.011156326, 0.013522214, -0.020646535, -0.01211601, 0.055928253, 0.011596181, -0.017247654, 0.0005939711, -0.026977783, -0.003942035, -0.009583511, -0.0055248477, -0.028737204, 0.023179034, 0.003995351, 0.0219661, -0.008470545, 0.023392297, 0.010469886, -0.015874773, 0.007890735, -0.009690142, -0.00024970944, 0.012775794, 0.0114762215, 0.013422247, 0.010429899, -0.03686786, -0.006717788, -0.027484283, 0.011556195, -0.036068123, -0.013915418, -0.0016327957, 0.0151016945, -0.020473259, 0.004671795, -0.012555866, 0.0209531, 0.01982014, 0.024485271, 0.0105431955, -0.005178295, 0.033162415, -0.013795458, 0.007150979, 0.010243294, 0.005644808, 0.017260984, -0.0045618312, 0.0024725192, 0.004305249, -0.008197301, 0.0014203656, 0.0018460588, 0.005015015, -0.011142998, 0.01439526, 0.022965772, 0.02552493, 0.007757446, -0.0019726837, 0.009503538, -0.032042783, 0.008403899, -0.04609149, 0.013808787, 0.011749465, 0.036388017, 0.016314628, 0.021939443, -0.0250051, -0.017354285, -0.012962398, 0.00006107364, 0.019113706, 0.03081652, -0.018114036, -0.0084572155, 0.009643491, -0.0034721901, 0.0072642746, -0.0090636825, 0.01642126, 0.013428912, 0.027724205, 0.0071243206, -0.6858542, -0.031029783, -0.014595194, -0.011449563, 0.017514233, 0.01743426, 0.009950057, 0.0029706885, -0.015714826, -0.001806072, 0.011856096, 0.026444625, -0.0010663156, -0.006474535, 0.0016161345, -0.020313311, 0.0148351155, -0.0018393943, 0.0057347785, 0.018300641, -0.018647194, 0.03345565, -0.008070676, 0.0071443142, 0.014301958, 0.0044818576, 0.003838736, -0.007350913, -0.024525259, -0.001142124, -0.018620536, 0.017247654, 0.007037683, 0.010236629, 0.06046009, 0.0138887605, -0.012122675, 0.037694257, 0.0055081863, 0.042492677, 0.00021784494, -0.011656162, 0.010276617, 0.022325981, 0.005984696, -0.009496873, 0.013382261, -0.0010563189, 0.0026507939, -0.041639622, 0.008637156, 0.026471283, -0.008403899, 0.024858482, -0.00066686375, -0.0016252982, 0.027590916, 0.0051449724, 0.0058647357, -0.008743787, -0.014968405, 0.027724205, -0.011596181, 0.0047650975, -0.015381602, 0.0043718936, 0.002159289, 0.035908177, -0.008243952, -0.030443309, 0.027564257, 0.042625964, -0.0033688906, 0.01843393, 0.019087048, 0.024578573, 0.03268257, -0.015608194, -0.014128681, -0.0033538956, -0.0028757197, -0.004121976, -0.032389335, 0.0034322033, 0.058807302, 0.010943064, -0.030523283, 0.008903735, 0.017500903, 0.00871713, -0.0029406983, 0.013995391, -0.03132302, -0.019660193, -0.00770413, -0.0038853872, 0.0015894766, -0.0015294964, -0.006251275, -0.021099718, -0.010256623, -0.008863748, 0.028550599, 0.02020668, -0.0012962399, -0.003415542, -0.0022509254, 0.0119360695, 0.027590916, -0.046971202, -0.0015194997, -0.022405956, 0.0016677842, -0.00018535563, -0.015421589, -0.031802863, 0.03814744, 0.0065411795, 0.016567878, -0.015621523, 0.022899127, -0.011076353, 0.02841731, -0.002679118, -0.002342562, 0.015341615, 0.01804739, -0.020566562, -0.012989056, -0.002990682, 0.01643459, 0.00042527664, 0.008243952, -0.013715484, -0.004835075, -0.009803439, 0.03129636, -0.021432944, 0.0012087687, -0.015741484, -0.0052016205, 0.00080890034, -0.01755422, 0.004811749, -0.017967418, -0.026684547, -0.014128681, 0.0041386373, -0.013742141, -0.010056688, -0.013268964, -0.0110630235, -0.028337335, 0.015981404, -0.00997005, -0.02424535, -0.013968734, -0.028310679, -0.027750863, -0.020699851, 0.02235264, 0.001057985, 0.00081639783, -0.0099367285, 0.013522214, -0.012016043, -0.00086471526, 0.013568865, 0.0019376953, -0.019020405, 0.017460918, -0.023045745, 0.008503866, 0.0064678704, -0.011509543, 0.018727167, -0.003372223, -0.0028690554, -0.0027024434, -0.011902748, -0.012182655, -0.015714826, -0.0098634185, 0.00593138, 0.018753825, 0.0010146659, 0.013029044, 0.0003521757, -0.017620865, 0.04102649, 0.00552818, 0.024485271, -0.009630162, -0.015608194, 0.0006718621, -0.0008418062, 0.012395918, 0.0057980907, 0.016221326, 0.010616505, 0.004838407, -0.012402583, 0.019900113, -0.0034521967, 0.000247002, -0.03153628, 0.0011038032, -0.020819811, 0.016234655, -0.00330058, -0.0032289368, 0.00078973995, -0.021952773, -0.022459272, 0.03118973, 0.03673457, -0.021472929, 0.0072109587, -0.015075036, 0.004855068, -0.0008151483, 0.0069643734, 0.010023367, -0.010276617, -0.023019087, 0.0068244194, -0.0012520878, -0.0015086699, 0.022046074, -0.034148756, -0.0022192693, 0.002427534, -0.0027124402, 0.0060346797, 0.015461575, 0.0137554705, 0.009230294, -0.009583511, 0.032629255, 0.015994733, -0.019167023, -0.009203636, 0.03393549, -0.017274313, -0.012042701, -0.0009930064, 0.026777849, -0.013582194, -0.0027590916, -0.017594207, -0.026804507, -0.0014236979, -0.022032745, 0.0091236625, -0.0042419364, -0.00858384, -0.0033905501, -0.020739838, 0.016821127, 0.022539245, 0.015381602, 0.015141681, 0.028817179, -0.019726837, -0.0051283115, -0.011489551, -0.013208984, -0.0047017853, -0.0072309524, 0.01767418, 0.0025658219, -0.010323267, 0.012609182, -0.028097415, 0.026871152, -0.010276617, 0.021912785, 0.0022542577, 0.005124979, -0.0019710176, 0.004518512, -0.040360045, 0.010969722, -0.0031539614, -0.020366628, -0.025778178, -0.0110030435, -0.016221326, 0.0036587953, 0.016207997, 0.003007343, -0.0032555948, 0.0044052163, -0.022046074, -0.0008822095, -0.009363583, 0.028230704, -0.024538586, 0.0029840174, 0.0016044717, -0.014181997, 0.031349678, -0.014381931, -0.027750863, 0.02613806, 0.0004136138, -0.005748107, -0.01868718, -0.0010138329, 0.0054348772, 0.010703143, -0.003682121, 0.0030856507, -0.004275259, -0.010403241, 0.021113047, -0.022685863, -0.023032416, 0.031429652, 0.001792743, -0.005644808, -0.011842767, -0.04078657, -0.0026874484, 0.06915057, -0.00056939584, -0.013995391, 0.010703143, -0.013728813, -0.022939114, -0.015261642, -0.022485929, 0.016807798, 0.007964044, 0.0144219175, 0.016821127, 0.0076241563, 0.005461535, -0.013248971, 0.015301628, 0.0085171955, -0.004318578, 0.011136333, -0.0059047225, -0.010249958, -0.018207338, 0.024645219, 0.021752838, 0.0007614159, -0.013648839, 0.01111634, -0.010503208, -0.0038487327, -0.008203966, -0.00397869, 0.0029740208, 0.008530525, 0.005261601, 0.01642126, -0.0038753906, -0.013222313, 0.026537929, 0.024671877, -0.043505676, 0.014195326, 0.024778508, 0.0056914594, -0.025951454, 0.017620865, -0.0021359634, 0.008643821, 0.021299653, 0.0041686273, -0.009017031, 0.04044002, 0.024378639, -0.027777521, -0.014208655, 0.0028623908, 0.042119466, 0.005801423, -0.028124074, -0.03129636, 0.022139376, -0.022179363, -0.04067994, 0.013688826, 0.013328944, 0.0046184794, -0.02828402, -0.0063412455, -0.0046184794, -0.011756129, -0.010383247, -0.0018543894, -0.0018593877, -0.00052024535, 0.004815081, 0.014781799, 0.018007403, 0.01306903, -0.020433271, 0.009043689, 0.033189073, -0.006844413, -0.019766824, -0.018767154, 0.00533491, -0.0024575242, 0.018727167, 0.0058080875, -0.013835444, 0.0040719924, 0.004881726, 0.012029372, 0.005664801, 0.03193615, 0.0058047553, 0.002695779, 0.009290274, 0.02361889, 0.017834127, 0.0049017193, -0.0036388019, 0.010776452, -0.019793482, 0.0067777685, -0.014208655, -0.024911797, 0.002385881, 0.0034988478, 0.020899786, -0.0025858153, -0.011849431, 0.033189073, -0.021312982, 0.024965113, -0.014635181, 0.014048708, -0.0035921505, -0.003347231, 0.030869836, -0.0017161017, -0.0061346465, 0.009203636, -0.025165047, 0.0068510775, 0.021499587, 0.013782129, -0.0024475274, -0.0051149824, -0.024445284, 0.006167969, 0.0068844, -0.00076183246, 0.030150073, -0.0055948244, -0.011162991, -0.02057989, -0.009703471, -0.020646535, 0.008004031, 0.0066378145, -0.019900113, -0.012169327, -0.01439526, 0.0044252095, -0.004018677, 0.014621852, -0.025085073, -0.013715484, -0.017980747, 0.0071043274, 0.011456228, -0.01010334, -0.0035321703, -0.03801415, -0.012036037, -0.0028990454, -0.05419549, -0.024058744, -0.024272008, 0.015221654, 0.027964126, 0.03182952, -0.015354944, 0.004855068, 0.011522872, 0.004771762, 0.0027874154, 0.023405626, 0.0004242353, -0.03132302, 0.007057676, 0.008763781, -0.0027057757, 0.023005757, -0.0071176565, -0.005238275, 0.029110415, -0.010989714, 0.013728813, -0.009630162, -0.029137073, -0.0049317093, -0.0008630492, -0.015248313, 0.0043219104, -0.0055681667, -0.013175662, 0.029723546, 0.025098402, 0.012849103, -0.0009996708, 0.03118973, -0.0021709518, 0.0260181, -0.020526575, 0.028097415, -0.016141351, 0.010509873, -0.022965772, 0.002865723, 0.0020493253, 0.0020509914, -0.0041419696, -0.00039695262, 0.017287642, 0.0038987163, 0.014795128, -0.014661839, -0.008950386, 0.004431874, -0.009383577, 0.0012604183, -0.023019087, 0.0029273694, -0.033135757, 0.009176978, -0.011023037, -0.002102641, 0.02663123, -0.03849399, -0.0044152127, 0.0004527676, -0.0026924468, 0.02828402, 0.017727496, 0.035135098, 0.02728435, -0.005348239, -0.001467017, -0.019766824, 0.014715155, 0.011982721, 0.0045651635, 0.023458943, -0.0010046692, -0.0031373003, -0.0006972704, 0.0019043729, -0.018967088, -0.024311995, 0.0011546199, 0.007977373, -0.004755101, -0.010016702, -0.02780418, -0.004688456, 0.013022379, -0.005484861, 0.0017227661, -0.015394931, -0.028763862, -0.026684547, 0.0030589928, -0.018513903, 0.028363993, 0.0044818576, -0.009270281, 0.038920518, -0.016008062, 0.0093902415, 0.004815081, -0.021059733, 0.01451522, -0.0051583014, 0.023765508, -0.017874114, -0.016821127, -0.012522544, -0.0028390652, 0.0040886537, 0.020259995, -0.031216389, -0.014115352, -0.009176978, 0.010303274, 0.020313311, 0.0064112223, -0.02235264, -0.022872468, 0.0052449396, 0.0005723116, 0.0037321046, 0.016807798, -0.018527232, -0.009303603, 0.0024858483, -0.0012662497, -0.007110992, 0.011976057, -0.007790768, -0.042999174, -0.006727785, -0.011829439, 0.007024354, 0.005278262, -0.017740825, -0.0041519664, 0.0085905045, 0.027750863, -0.038387362, 0.024391968, 0.00087721116, 0.010509873, -0.00038508154, -0.006857742, 0.0183273, -0.0037054466, 0.015461575, 0.0017394272, -0.0017944091, 0.014181997, -0.0052682655, 0.009023695, 0.00719763, -0.013522214, 0.0034422, 0.014941746, -0.0016711164, -0.025298337, -0.017634194, 0.0058714002, -0.005321581, 0.017834127, 0.0110630235, -0.03369557, 0.029190388, -0.008943722, 0.009363583, -0.0034222065, -0.026111402, -0.007037683, -0.006561173, 0.02473852, -0.007084334, -0.010110005, -0.008577175, 0.0030439978, -0.022712521, 0.0054582027, -0.0012620845, -0.0011954397, -0.015741484, 0.0129557345, -0.00042111133, 0.00846388, 0.008930393, 0.016487904, 0.010469886, -0.007917393, -0.011762793, -0.0214596, 0.000917198, 0.021672864, 0.010269952, -0.007737452, -0.010243294, -0.0067244526, -0.015488233, -0.021552904, 0.017127695, 0.011109675, 0.038067464, 0.00871713, -0.0025591573, 0.021312982, -0.006237946, 0.034628596, -0.0045251767, 0.008357248, 0.020686522, 0.0010696478, 0.0076708077, 0.03772091, -0.018700508, -0.0020676525, -0.008923728, -0.023298996, 0.018233996, -0.010256623, 0.0017860786, 0.009796774, -0.00897038, -0.01269582, -0.018527232, 0.009190307, -0.02372552, -0.042119466, 0.008097334, -0.0066778013, -0.021046404, 0.0019593548, 0.011083017, -0.0016028056, 0.012662497, -0.000059095124, 0.0071043274, -0.014675168, 0.024831824, -0.053582355, 0.038387362, 0.0005698124, 0.015954746, 0.021552904, 0.031589597, -0.009230294, -0.0006147976, 0.002625802, -0.011749465, -0.034362018, -0.0067844326, -0.018793812, 0.011442899, -0.008743787, 0.017474247, -0.021619547, 0.01831397, -0.009037024, -0.0057247817, -0.02728435, 0.010363255, 0.034415334, -0.024032086, -0.0020126705, -0.0045518344, -0.019353628, -0.018340627, -0.03129636, -0.0034038792, -0.006321252, -0.0016161345, 0.033642255, -0.000056075285, -0.005005019, 0.004571828, -0.0024075406, -0.00010215386, 0.0098634185, 0.1980148, -0.003825407, -0.025191706, 0.035161756, 0.005358236, 0.025111731, 0.023485601, 0.0023342315, -0.011882754, 0.018287312, -0.0068910643, 0.003912045, 0.009243623, -0.001355387, -0.028603915, -0.012802451, -0.030150073, -0.014795128, -0.028630573, -0.0013487226, 0.002667455, 0.00985009, -0.0033972147, -0.021486258, 0.009503538, -0.017847456, 0.013062365, -0.014341944, 0.005078328, 0.025165047, -0.015594865, -0.025924796, -0.0018177348, 0.010996379, -0.02993681, 0.007324255, 0.014475234, -0.028577257, 0.005494857, 0.00011725306, -0.013315615, 0.015941417, 0.009376912, 0.0025158382, 0.008743787, 0.023832154, -0.008084005, -0.014195326, -0.008823762, 0.0033455652, -0.032362677, -0.021552904, -0.0056081535, 0.023298996, -0.025444955, 0.0097301295, 0.009736794, 0.015274971, -0.0012937407, -0.018087378, -0.0039387033, 0.008637156, -0.011189649, -0.00023846315, -0.011582852, 0.0066411467, -0.018220667, 0.0060846633, 0.0376676, -0.002709108, 0.0072776037, 0.0034188742, -0.010249958, -0.0007747449, -0.00795738, -0.022192692, 0.03910712, 0.032122757, 0.023898797, 0.0076241563, -0.007397564, -0.003655463, 0.011442899, -0.014115352, -0.00505167, -0.031163072, 0.030336678, -0.006857742, -0.022259338, 0.004048667, 0.02072651, 0.0030156737, -0.0042119464, 0.00041861215, -0.005731446, 0.011103011, 0.013822115, 0.021512916, 0.009216965, -0.006537847, -0.027057758, -0.04054665, 0.010403241, -0.0056281467, -0.005701456, -0.002709108, -0.00745088, -0.0024841821, 0.009356919, -0.022659205, 0.004061996, -0.013175662, 0.017074378, -0.006141311, -0.014541878, 0.02993681, -0.00028448965, -0.025271678, 0.011689484, -0.014528549, 0.004398552, -0.017274313, 0.0045751603, 0.012455898, 0.004121976, -0.025458284, -0.006744446, 0.011822774, -0.015035049, -0.03257594, 0.014675168, -0.0039187097, 0.019726837, -0.0047251107, 0.0022825818, 0.011829439, 0.005391558, -0.016781142, -0.0058747325, 0.010309938, -0.013049036, 0.01186276, -0.0011246296, 0.0062112883, 0.0028190718, -0.021739509, 0.009883412, -0.0073175905, -0.012715813, -0.017181009, -0.016607866, -0.042492677, -0.0014478565, -0.01794076, 0.012302616, -0.015194997, -0.04433207, -0.020606548, 0.009696807, 0.010303274, -0.01694109, -0.004018677, 0.019353628, -0.001991011, 0.000058938927, 0.010536531, -0.17274313, 0.010143327, 0.014235313, -0.024152048, 0.025684876, -0.0012504216, 0.036601283, -0.003698782, 0.0007310093, 0.004165295, -0.0029157067, 0.017101036, -0.046891227, -0.017460918, 0.022965772, 0.020233337, -0.024072073, 0.017220996, 0.009370248, 0.0010363255, 0.0194336, -0.019606877, 0.01818068, -0.020819811, 0.007410893, 0.0019326969, 0.017887443, 0.006651143, 0.00067394477, -0.011889419, -0.025058415, -0.008543854, 0.021579562, 0.0047484366, 0.014062037, 0.0075508473, -0.009510202, -0.009143656, 0.0046817916, 0.013982063, -0.0027990784, 0.011782787, 0.014541878, -0.015701497, -0.029350337, 0.021979429, 0.01332228, -0.026244693, -0.0123492675, -0.003895384, 0.0071576433, -0.035454992, -0.00046984528, 0.0033522295, 0.039347045, 0.0005119148, 0.00476843, -0.012995721, 0.0024042083, -0.006931051, -0.014461905, -0.0127558, 0.0034555288, -0.0074842023, -0.030256703, -0.007057676, -0.00807734, 0.007804097, -0.006957709, 0.017181009, -0.034575284, -0.008603834, -0.005008351, -0.015834786, 0.02943031, 0.016861115, -0.0050849924, 0.014235313, 0.0051449724, 0.0025924798, -0.0025741523, 0.04289254, -0.002104307, 0.012969063, -0.008310596, 0.00423194, 0.0074975314, 0.0018810473, -0.014248641, -0.024725191, 0.0151016945, -0.017527562, 0.0018727167, 0.0002830318, 0.015168339, 0.0144219175, -0.004048667, -0.004358565, 0.011836103, -0.010343261, -0.005911387, 0.0022825818, 0.0073175905, 0.00403867, 0.013188991, 0.03334902, 0.006111321, 0.008597169, 0.030123414, -0.015474904, 0.0017877447, -0.024551915, 0.013155668, 0.023525586, -0.0255116, 0.017220996, 0.004358565, -0.00934359, 0.0099967085, 0.011162991, 0.03092315, -0.021046404, -0.015514892, 0.0011946067, -0.01816735, 0.010876419, -0.10124666, -0.03550831, 0.0056348112, 0.013942076, 0.005951374, 0.020419942, -0.006857742, -0.020873128, -0.021259667, 0.0137554705, 0.0057880944, -0.029163731, -0.018767154, -0.021392956, 0.030896494, -0.005494857, -0.0027307675, -0.006801094, -0.014821786, 0.021392956, -0.0018110704, -0.0018843795, -0.012362596, -0.0072176233, -0.017194338, -0.018713837, -0.024272008, 0.03801415, 0.00015880188, 0.0044951867, -0.028630573, -0.0014070367, -0.00916365, -0.026537929, -0.009576847, -0.013995391, -0.0077107945, 0.0050016865, 0.00578143, -0.04467862, 0.008363913, 0.010136662, -0.0006268769, -0.006591163, 0.015341615, -0.027377652, -0.00093136, 0.029243704, -0.020886457, -0.01041657, -0.02424535, 0.005291591, -0.02980352, -0.009190307, 0.019460259, -0.0041286405, 0.004801752, 0.0011787785, -0.001257086, -0.011216307, -0.013395589, 0.00088137644, -0.0051616337, 0.03876057, -0.0033455652, 0.00075850025, -0.006951045, -0.0062112883, 0.018140694, -0.006351242, -0.008263946, 0.018154023, -0.012189319, 0.0075508473, -0.044358727, -0.0040153447, 0.0093302615, -0.010636497, 0.032789204, -0.005264933, -0.014235313, -0.018393943, 0.007297597, -0.016114693, 0.015021721, 0.020033404, 0.0137688, 0.0011046362, 0.010616505, -0.0039453674, 0.012109346, 0.021099718, -0.0072842683, -0.019153694, -0.003768759, 0.039320387, -0.006747778, -0.0016852784, 0.018154023, 0.0010963057, -0.015035049, -0.021033075, -0.04345236, 0.017287642, 0.016341286, -0.008610498, 0.00236922, 0.009290274, 0.028950468, -0.014475234, -0.0035654926, 0.015434918, -0.03372223, 0.004501851, -0.012929076, -0.008483873, -0.0044685286, -0.0102233, 0.01615468, 0.0022792495, 0.010876419, -0.0059647025, 0.01895376, -0.0069976957, -0.0042952523, 0.017207667, -0.00036133936, 0.0085905045, 0.008084005, 0.03129636, -0.016994404, -0.014915089, 0.020100048, -0.012009379, -0.006684466, 0.01306903, 0.00015765642, -0.00530492, 0.0005277429, 0.015421589, 0.015528221, 0.032202728, -0.003485519, -0.0014286962, 0.033908837, 0.001367883, 0.010509873, 0.025271678, -0.020993087, 0.019846799, 0.006897729, -0.010216636, -0.00725761, 0.01818068, -0.028443968, -0.011242964, -0.014435247, -0.013688826, 0.006101324, -0.0022509254, 0.013848773, -0.0019077052, 0.017181009, 0.03422873, 0.005324913, -0.0035188415, 0.014128681, -0.004898387, 0.005038341, 0.0012320944, -0.005561502, -0.017847456, 0.0008538855, -0.0047884234, 0.011849431, 0.015421589, -0.013942076, 0.0029790192, -0.013702155, 0.0001199605, -0.024431955, 0.019926772, 0.022179363, -0.016487904, -0.03964028, 0.0050849924, 0.017487574, 0.022792496, 0.0012504216, 0.004048667, -0.00997005, 0.0076041627, -0.014328616, -0.020259995, 0.0005598157, -0.010469886, 0.0016852784, 0.01716768, -0.008990373, -0.001987679, 0.026417969, 0.023792166, 0.0046917885, -0.0071909656, -0.00032051947, -0.023259008, -0.009170313, 0.02071318, -0.03156294, -0.030869836, -0.006324584, 0.013795458, -0.00047151142, 0.016874444, 0.00947688, 0.00985009, -0.029883493, 0.024205362, -0.013522214, -0.015075036, -0.030603256, 0.029270362, 0.010503208, 0.021539574, 0.01743426, -0.023898797, 0.022019416, -0.0068777353, 0.027857494, -0.021259667, 0.0025758184, 0.006197959, 0.006447877, -0.00025200035, -0.004941706, -0.021246338, -0.005504854, -0.008390571, -0.0097301295, 0.027244363, -0.04446536, 0.05216949, 0.010243294, -0.016008062, 0.0122493, -0.0199401, 0.009077012, 0.019753495, 0.006431216, -0.037960835, -0.027377652, 0.016381273, -0.0038620618, 0.022512587, -0.010996379, -0.0015211658, -0.0102233, 0.007071005, 0.008230623, -0.009490209, -0.010083347, 0.024431955, 0.002427534, 0.02828402, 0.0035721571, -0.022192692, -0.011882754, 0.010056688, 0.0011904413, -0.01426197, -0.017500903, -0.00010985966, 0.005591492, -0.0077707744, -0.012049366, 0.011869425, 0.00858384, -0.024698535, -0.030283362, 0.020140035, 0.011949399, -0.013968734, 0.042732596, -0.011649498, -0.011982721, -0.016967745, -0.0060913274, -0.007130985, -0.013109017, -0.009710136 + ])), + 'numCandidates': 150, + 'limit': 10 + } + }, { + '$project': { + '_id': 0, + 'plot': 1, + 'title': 1, + 'score': { + '$meta': 'vectorSearchScore' + } + } + } + ]; + // Runs pipeline + const result = coll.aggregate(agg); + + // Prints results + for await (const doc of result) { + console.log(doc); + } + } finally { + await client.close(); + } +} +run().catch(console.dir); \ No newline at end of file diff --git a/source/index.txt b/source/index.txt index 7cc4d3878..86b98e248 100644 --- a/source/index.txt +++ b/source/index.txt @@ -16,19 +16,23 @@ MongoDB Node Driver :titlesonly: :maxdepth: 1 - Quick Start - Quick Reference - What's New + Get Started + Connect + CRUD Operations + Promises + Aggregation + Data Formats + Indexes + Run a Database Command + Atlas Search + Atlas Vector Search + Monitoring and Logging + Security Usage Examples - Fundamentals - Aggregation Tutorials + Reference + TypeScript API Documentation <{+api+}> - FAQ - Connection Troubleshooting Issues & Help - Compatibility - Upgrade - Release Notes View the Source Introduction @@ -46,80 +50,85 @@ deployments hosted in the following environments: .. include:: /includes/fact-environments.rst -Quick Start +Get Started ----------- Learn how to establish a connection to MongoDB Atlas and begin -working with data in the step-by-step :doc:`Quick Start `. +working with data in the step-by-step :doc:`Get Started ` tutorial. -Quick Reference ---------------- +Connect to MongoDB +------------------ -See driver syntax examples for common MongoDB commands in the -:ref:`Quick Reference ` section. +Learn how to create and configure a connection to a MongoDB deployment in the +:ref:`` section. -What's New ----------- +Read and Write Data +------------------- -For a list of new features and changes in each version, see the -:ref:`What's New ` section. +Learn how to find, update, and delete data in the :ref:`` section. -Usage Examples --------------- +Transform Your Data with Aggregation +------------------------------------- -For fully runnable code snippets and explanations for common -methods, see the :doc:`Usage Examples ` section. +Learn how to use the {+driver-short+} to perform aggregation operations in the +:ref:`` section. -Fundamentals +Data Formats ------------ -.. include:: /includes/fundamentals-sections.rst +Learn how to work with BSON and other data formats in the +:ref:`` section. -Aggregation Tutorials ---------------------- +Optimize Queries with Indexes +----------------------------- -For step-by-step explanations of common -aggregation tasks, see the :ref:`node-aggregation-tutorials-landing` -section. +Learn how to work with common types of indexes in the :ref:`` section. -API ---- +Run a Database Command +---------------------- -For detailed information about classes and methods in the MongoDB -Node.js driver, see the `{+driver-long+} API documentation -<{+api+}>`__. +Learn how to run a database command in the :ref:`` section. -FAQ ---- +Atlas Search +------------ -For answers to commonly asked questions about the MongoDB -Node.js Driver, see the :doc:`Frequently Asked Questions (FAQ) ` -section. +Learn how to run Atlas Search queries in the :ref:`` section. -Connection Troubleshooting --------------------------- +Atlas Vector Search +------------------- -For solutions to issues you might encounter when using the driver to connect to -a MongoDB deployment, see the :ref:`node-connection-troubleshooting` section. +Learn how to run Atlas Vector Search queries in the :ref:`` section. -Issues & Help -------------- +Monitoring and Logging +---------------------- -Learn how to report bugs, contribute to the driver, and to find help in the -:doc:`Issues & Help ` section. +Learn how to monitor changes to your application and write them to logs in the +:ref:`` section. -Compatibility -------------- +Secure Your Data +---------------- + +Learn about ways you can authenticate your application and encrypt your data in +the :ref:`` section. -For the compatibility tables that show the recommended {+driver-short+} -version for each {+mdb-server+} version, see the -:doc:`Compatibility ` section. +Reference +--------- -Upgrade Driver Versions ------------------------ +Find more information about {+driver-short+} versions, compatibility, and third-party tools in the +:doc:`Reference ` section. -Learn what changes you must make to your application to upgrade -driver versions in the :ref:`` section. +API Documentation +----------------- + +For detailed information about classes and methods in the MongoDB +Node.js driver, see the `{+driver-long+} API documentation +<{+api+}>`__. + +Issues & Help +------------- + +Learn how to report bugs, contribute to the driver, and to find help in the +:doc:`Issues & Help ` section. Related Tools and Libraries --------------------------- diff --git a/source/fundamentals/indexes.txt b/source/indexes.txt similarity index 99% rename from source/fundamentals/indexes.txt rename to source/indexes.txt index 6dd6c01f8..56938d909 100644 --- a/source/fundamentals/indexes.txt +++ b/source/indexes.txt @@ -1,8 +1,9 @@ .. _node-fundamentals-indexes: +.. _node-indexes: -======= -Indexes -======= +====================== +Indexes on Collections +====================== .. facet:: :name: genre @@ -258,7 +259,7 @@ MongoDB supports queries of geospatial coordinate data using **2dsphere indexes**. With a 2dsphere index, you can query the geospatial data for inclusion, intersection, and proximity. For more information on querying geospatial data with the MongoDB Node.js driver, read our -:doc:`Search Geospatial ` guide. +:doc:`Search Geospatial ` guide. To create a 2dsphere index, you must specify a field that contains only **GeoJSON objects**. For more details on this type, see the MongoDB diff --git a/source/monitoring-and-logging.txt b/source/monitoring-and-logging.txt new file mode 100644 index 000000000..955baae1b --- /dev/null +++ b/source/monitoring-and-logging.txt @@ -0,0 +1,25 @@ +.. _node-monitoring-logging: + +====================== +Monitoring and Logging +====================== + +.. meta:: + :keywords: event + :description: Learn how to monitor and log events by using the {+driver-long+}. + +.. toctree:: + + Monitoring + Logging + Change Streams + +Overview +-------- + +Learn how to set up monitoring and logging for your application in the following +sections: + +- :ref:`Monitoring ` +- :doc:`/monitoring-and-logging/logging` +- :doc:`/monitoring-and-logging/change-streams` diff --git a/source/usage-examples/changeStream.txt b/source/monitoring-and-logging/change-streams.txt similarity index 94% rename from source/usage-examples/changeStream.txt rename to source/monitoring-and-logging/change-streams.txt index 64bdd0d39..46db9b3f1 100644 --- a/source/usage-examples/changeStream.txt +++ b/source/monitoring-and-logging/change-streams.txt @@ -1,10 +1,18 @@ .. _node-usage-watch: +.. _node-change-streams: -================= -Watch for Changes -================= +================================ +Monitor Data with Change Streams +================================ -.. default-domain:: mongodb +.. meta:: + :description: Monitor changes in MongoDB using the watch() method in the MongoDB Node.js Driver on collections, databases, or clients to open change streams and handle change events. + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecols Open a Change Stream -------------------- diff --git a/source/fundamentals/logging.txt b/source/monitoring-and-logging/logging.txt similarity index 100% rename from source/fundamentals/logging.txt rename to source/monitoring-and-logging/logging.txt diff --git a/source/monitoring-and-logging/monitoring.txt b/source/monitoring-and-logging/monitoring.txt new file mode 100644 index 000000000..b6c5ad841 --- /dev/null +++ b/source/monitoring-and-logging/monitoring.txt @@ -0,0 +1,26 @@ +.. _node-monitoring: + +========== +Monitoring +========== + +.. meta:: + :description: Explore cluster, command, and connection pool monitoring in the MongoDB Node.js Driver. + +.. facet:: + :name: genre + :values: reference + +.. toctree:: + :caption: CRUD Operations + + Cluster + Command + Connection Pool + +- :doc:`Cluster Monitoring `: monitoring + changes in a cluster +- :doc:`Command Monitoring `: monitoring + the execution status of commands +- :doc:`Connection Pool Monitoring `: monitoring + the driver's connection pool \ No newline at end of file diff --git a/source/fundamentals/monitoring/cluster-monitoring.txt b/source/monitoring-and-logging/monitoring/cluster-monitoring.txt similarity index 100% rename from source/fundamentals/monitoring/cluster-monitoring.txt rename to source/monitoring-and-logging/monitoring/cluster-monitoring.txt diff --git a/source/fundamentals/monitoring/command-monitoring.txt b/source/monitoring-and-logging/monitoring/command-monitoring.txt similarity index 100% rename from source/fundamentals/monitoring/command-monitoring.txt rename to source/monitoring-and-logging/monitoring/command-monitoring.txt diff --git a/source/fundamentals/monitoring/connection-monitoring.txt b/source/monitoring-and-logging/monitoring/connection-monitoring.txt similarity index 100% rename from source/fundamentals/monitoring/connection-monitoring.txt rename to source/monitoring-and-logging/monitoring/connection-monitoring.txt diff --git a/source/fundamentals/promises.txt b/source/promises.txt similarity index 100% rename from source/fundamentals/promises.txt rename to source/promises.txt diff --git a/source/quick-start.txt b/source/quick-start.txt deleted file mode 100644 index 0ebfed6a7..000000000 --- a/source/quick-start.txt +++ /dev/null @@ -1,45 +0,0 @@ -.. _node-quickstart: - -======================= -Node Driver Quick Start -======================= - -.. facet:: - :name: genre - :values: tutorial - -.. meta:: - :description: Learn how to create an app to connect to MongoDB deployment by using the Node.js driver. - :keywords: node.js - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -.. toctree:: - - Download & Install - Create a Deployment - Create a Connection String - Connect to MongoDB - Next Steps - -Overview --------- - -This guide shows you how to create an application that uses the -{+driver-long+} to connect to a MongoDB cluster hosted on MongoDB Atlas. If -you prefer to connect to MongoDB using a different driver or programming -language, see our :driver:`list of official drivers <>`. - -The {+driver-short+} is a library of functions that you can use to connect -to and communicate with MongoDB. - -MongoDB Atlas is a fully managed cloud database service that hosts your -MongoDB deployments. You can create your own free (no credit card -required) MongoDB Atlas deployment by following the steps in this guide. - -Follow the steps in this guide to connect a sample Node.js application to -a MongoDB Atlas deployment. diff --git a/source/quick-start/connect-to-mongodb.txt b/source/quick-start/connect-to-mongodb.txt deleted file mode 100644 index 94f8b753a..000000000 --- a/source/quick-start/connect-to-mongodb.txt +++ /dev/null @@ -1,78 +0,0 @@ -.. _node-quick-start-connect-to-mongodb: - -================== -Connect to MongoDB -================== - -.. procedure:: - :style: connected - - .. step:: Create your Node.js Application - - Create a file to contain your application called ``index.js`` in your - ``node_quickstart`` project directory. - - Copy and paste the following code into the ``index.js`` file: - - .. code-block:: js - - const { MongoClient } = require("mongodb"); - - // Replace the uri string with your connection string. - const uri = ""; - - const client = new MongoClient(uri); - - async function run() { - try { - const database = client.db('sample_mflix'); - const movies = database.collection('movies'); - - // Query for a movie that has the title 'Back to the Future' - const query = { title: 'Back to the Future' }; - const movie = await movies.findOne(query); - - console.log(movie); - } finally { - // Ensures that the client will close when you finish/error - await client.close(); - } - } - run().catch(console.dir); - - .. step:: Assign the Connection String - - Replace the ```` placeholder with the - connection string that you copied from the :ref:`node-quick-start-connection-string` - step of this guide. - - .. step:: Run your Node.js Application - - In your shell, run the following command to start this application: - - .. code-block:: none - - node index.js - - The output includes details of the retrieved movie document: - - .. code-block:: none - - { - _id: ..., - plot: 'A young man is accidentally sent 30 years into the past...', - genres: [ 'Adventure', 'Comedy', 'Sci-Fi' ], - ... - title: 'Back to the Future', - ... - } - - If you encounter an error or see no output, check whether you specified the - proper connection string in the ``index.js`` file, and that you loaded the - sample data. - -After you complete these steps, you have a working application that -uses the driver to connect to your MongoDB deployment, runs a query on -the sample data, and prints out the result. - -.. include:: /includes/quick-start/troubleshoot.rst diff --git a/source/quick-start/create-a-connection-string.txt b/source/quick-start/create-a-connection-string.txt deleted file mode 100644 index 448f33519..000000000 --- a/source/quick-start/create-a-connection-string.txt +++ /dev/null @@ -1,60 +0,0 @@ -.. _node-quick-start-connection-string: - -========================== -Create a Connection String -========================== - -You can connect to your MongoDB deployment by providing a -**connection URI**, also called a *connection string*, which -instructs the driver on how to connect to a MongoDB deployment -and how to behave while connected. - -The connection string includes the hostname or IP address and -port of your deployment, the authentication mechanism, user credentials -when applicable, and connection options. - -To connect to an instance or deployment not hosted on Atlas, see -:ref:`Other Ways to Connect to MongoDB `. - -.. procedure:: - :style: connected - - .. step:: Find your MongoDB Atlas Connection String - - To retrieve your connection string for the deployment that - you created in the :ref:`previous step `, - log into your Atlas account and navigate to the - :guilabel:`Clusters` section and click the :guilabel:`Connect` button - for your new deployment. - - .. figure:: /includes/figures/atlas_connect.png - :alt: The connect button in the clusters section of the Atlas UI - - Select the :guilabel:`Drivers` option from the :guilabel:`Connect to your application` - section. Then in the :guilabel:`Connecting with MongoDB Driver` - menu, select "Node.js" from the :guilabel:`Driver` selection menu and the version - that best matches the version you installed from the :guilabel:`Version` - selection menu. - - Select the :guilabel:`Password (SCRAM)` authentication mechanism. - - .. step:: Copy your Connection String - - Click the button on the right of the connection string to copy it to - your clipboard as shown in the following screenshot: - - .. figure:: /includes/figures/atlas_connection_copy_string.png - :alt: The connection string copy button in the Atlas UI - - .. step:: Update the Placeholders - - Paste this connection string into a a file in your preferred text editor - and replace the "" and "" placeholders with - your database user's username and password. - - Save this file to a safe location for use in the next step. - -After completing these steps, you have a connection string that -contains your database username and password. - -.. include:: /includes/quick-start/troubleshoot.rst diff --git a/source/quick-start/create-a-deployment.txt b/source/quick-start/create-a-deployment.txt deleted file mode 100644 index 2bd33caff..000000000 --- a/source/quick-start/create-a-deployment.txt +++ /dev/null @@ -1,29 +0,0 @@ -.. _node-quick-start-create-deployment: - -=========================== -Create a MongoDB Deployment -=========================== - -You can create a free tier MongoDB deployment on MongoDB Atlas -to store and manage your data. MongoDB Atlas hosts and manages -your MongoDB database in the cloud. - -.. procedure:: - :style: connected - - .. step:: Create a Free MongoDB deployment on Atlas - - Complete the :atlas:`Get Started with Atlas ` - guide to set up a new Atlas account and load sample data into a new free - tier MongoDB deployment. - - .. step:: Save your Credentials - - After you create your database user, save that user's - username and password to a safe location for use in an upcoming step. - -After you complete these steps, you have a new free tier MongoDB -deployment on Atlas, database user credentials, and sample data loaded -in your database. - -.. include:: /includes/quick-start/troubleshoot.rst diff --git a/source/quick-start/download-and-install.txt b/source/quick-start/download-and-install.txt deleted file mode 100644 index afd316859..000000000 --- a/source/quick-start/download-and-install.txt +++ /dev/null @@ -1,62 +0,0 @@ -.. _node-quick-start-download-and-install: - -==================== -Download and Install -==================== - -.. procedure:: - :style: connected - - .. step:: Install Node and npm - - Ensure you have Node.js {+min-node-version+} or later and - npm (Node Package Manager) installed in your development environment. - - For information on how to install Node.js and npm, see - `downloading and installing Node.js and npm `__. - - .. step:: Create a Project Directory - - In your shell, run the following command to create a - directory called ``node_quickstart`` for this project: - - .. code-block:: bash - - mkdir node_quickstart - - Run the following command to navigate into the project - directory: - - .. code-block:: bash - - cd node_quickstart - - Run the following command to initialize your Node.js project: - - .. code-block:: bash - - npm init -y - - When this command successfully completes, you have a ``package.json`` - file in your ``node_quickstart`` directory. - - - .. step:: Install the Node.js Driver - - Run the following command in your shell to install - the driver in your project directory: - - .. code-block:: bash - - npm install mongodb@{+version+} - - This command performs the following actions: - - - Downloads the ``mongodb`` package and the dependencies it requires - - Saves the package in the ``node_modules`` directory - - Records the dependency information in the ``package.json`` file - -After you complete these steps, you have Node.js and npm installed -and a new project directory with the driver dependencies installed. - -.. include:: /includes/quick-start/troubleshoot.rst diff --git a/source/quick-start/facets.toml b/source/quick-start/facets.toml deleted file mode 100644 index 07bd7b7f7..000000000 --- a/source/quick-start/facets.toml +++ /dev/null @@ -1,3 +0,0 @@ -[[facets]] -category = "genre" -value = "tutorial" diff --git a/source/quick-start/next-steps.txt b/source/quick-start/next-steps.txt deleted file mode 100644 index f15672dff..000000000 --- a/source/quick-start/next-steps.txt +++ /dev/null @@ -1,19 +0,0 @@ -.. _node-quick-start-next-steps: - -========== -Next Steps -========== - -Congratulations on completing the quick start tutorial! - -In this tutorial, you created a Node.js application that -connects to a MongoDB deployment hosted on MongoDB Atlas -and retrieves a document that matches a query. - -Learn more about the {+driver-long+} from the following resources: - -- Discover how to perform read and write operations in the - :ref:`CRUD Operations ` section. - -- See examples of frequently-used operations in the - :ref:`Usage Examples ` section. diff --git a/source/reference.txt b/source/reference.txt new file mode 100644 index 000000000..666cf2496 --- /dev/null +++ b/source/reference.txt @@ -0,0 +1,14 @@ +.. _node-reference: + +========== +Reference +========== + +.. toctree:: + :titlesonly: + :maxdepth: 1 + + Release Notes + Compatibility + Upgrade Guides + Quick Reference \ No newline at end of file diff --git a/source/compatibility.txt b/source/reference/compatibility.txt similarity index 100% rename from source/compatibility.txt rename to source/reference/compatibility.txt diff --git a/source/quick-reference.txt b/source/reference/quick-reference.txt similarity index 99% rename from source/quick-reference.txt rename to source/reference/quick-reference.txt index 000b93190..6cb1c5c21 100644 --- a/source/quick-reference.txt +++ b/source/reference/quick-reference.txt @@ -39,7 +39,7 @@ Compatibility | | `API Documentation <{+api+}/classes/Collection.html#findOne>`__ | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Query Operations ` - .. io-code-block:: :copyable: true diff --git a/source/whats-new.txt b/source/reference/release-notes.txt similarity index 99% rename from source/whats-new.txt rename to source/reference/release-notes.txt index c9667d996..7045d73fd 100644 --- a/source/whats-new.txt +++ b/source/reference/release-notes.txt @@ -1,8 +1,9 @@ .. _node-whats-new: +.. _node-release-notes: -========== -What's New -========== +============= +Release Notes +============= .. contents:: On this page :local: diff --git a/source/upgrade.txt b/source/reference/upgrade.txt similarity index 98% rename from source/upgrade.txt rename to source/reference/upgrade.txt index 05be1daac..fc6562251 100644 --- a/source/upgrade.txt +++ b/source/reference/upgrade.txt @@ -132,8 +132,9 @@ Version 6.0 Breaking Changes callback returns. In previous driver versions, this method returns the server command response, which varies depending on the MongoDB Server version or type that the driver connects to. To learn more - about transactions, see the :ref:`node-usage-txns` usage - examples and the :ref:`nodejs-transactions` guide. + about transactions, see the :ref:`Convenient Transaction API + ` and :ref:`Core API ` guides + and the :ref:`nodejs-transactions` guide. - Raised the optional ``kerberos`` dependency minimum version to 2.0.1 and removed support for version 1.x. - Raised the optional ``zstd`` dependency minimum version to 1.1.0. diff --git a/source/fundamentals/run-command.txt b/source/run-command.txt similarity index 98% rename from source/fundamentals/run-command.txt rename to source/run-command.txt index d8f27b2e3..efc077f86 100644 --- a/source/fundamentals/run-command.txt +++ b/source/run-command.txt @@ -1,8 +1,8 @@ .. _node-run-command: -============== -Run a Command -============== +====================== +Run a Database Command +====================== .. contents:: On this page :local: @@ -216,4 +216,4 @@ For more information about the concepts in this guide, see the following documen .. - :manual:`checkMetadataConsistency Command ` To learn how to retrieve data from a cursor, see the -:ref:`node-access-cursor` fundamentals page. +:ref:`node-access-cursor` guide. diff --git a/source/security.txt b/source/security.txt new file mode 100644 index 000000000..d3fc1817c --- /dev/null +++ b/source/security.txt @@ -0,0 +1,39 @@ +.. _node-security: + +================ +Secure Your Data +================ + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: ldap, encryption, principal, tls, authorize, boto, ecs, aws + :description: Learn how to use {+driver-short+} to secure your data. + +.. toctree:: + :titlesonly: + :maxdepth: 1 + + Authentication + In-Use Encryption + TLS Security Protocol + SOCKS Proxy + +Overview +-------- + +Learn how to set up security and authentication for your application +in the following sections: + +- :ref:`Authentication ` +- :ref:`In-Use Encryption ` +- :ref:`TLS Security Protocol ` +- :ref:`SOCKS Proxy ` diff --git a/source/fundamentals/authentication.txt b/source/security/authentication.txt similarity index 78% rename from source/fundamentals/authentication.txt rename to source/security/authentication.txt index f2b30c277..56d37b1e2 100644 --- a/source/fundamentals/authentication.txt +++ b/source/security/authentication.txt @@ -1,15 +1,17 @@ .. _node-authentication-mechanisms: +.. _node-authentication: ============== Authentication ============== -.. default-domain:: mongodb +.. meta:: + :description: Authenticate using the MongoDB Node.js Driver with various supported authentication mechanisms. .. toctree:: - Authentication - Enterprise Authentication + Authentication + Enterprise Authentication Overview -------- diff --git a/source/fundamentals/authentication/enterprise-mechanisms.txt b/source/security/authentication/enterprise-mechanisms.txt similarity index 100% rename from source/fundamentals/authentication/enterprise-mechanisms.txt rename to source/security/authentication/enterprise-mechanisms.txt diff --git a/source/fundamentals/authentication/mechanisms.txt b/source/security/authentication/mechanisms.txt similarity index 100% rename from source/fundamentals/authentication/mechanisms.txt rename to source/security/authentication/mechanisms.txt diff --git a/source/fundamentals/encrypt-fields.txt b/source/security/encrypt-fields.txt similarity index 100% rename from source/fundamentals/encrypt-fields.txt rename to source/security/encrypt-fields.txt diff --git a/source/fundamentals/connection/socks.txt b/source/security/socks.txt similarity index 99% rename from source/fundamentals/connection/socks.txt rename to source/security/socks.txt index 998d77a76..c0e414fe3 100644 --- a/source/fundamentals/connection/socks.txt +++ b/source/security/socks.txt @@ -1,4 +1,5 @@ .. _node-connect-socks: +.. _node-socks: =========================== Enable SOCKS5 Proxy Support diff --git a/source/fundamentals/connection/tls.txt b/source/security/tls.txt similarity index 99% rename from source/fundamentals/connection/tls.txt rename to source/security/tls.txt index 635140897..c27dffd96 100644 --- a/source/fundamentals/connection/tls.txt +++ b/source/security/tls.txt @@ -1,4 +1,5 @@ .. _node-connect-tls: +.. _node-tls: ========================== Enable TLS on a Connection diff --git a/source/fundamentals/typescript.txt b/source/typescript.txt similarity index 98% rename from source/fundamentals/typescript.txt rename to source/typescript.txt index f90f2976b..4a306578b 100644 --- a/source/fundamentals/typescript.txt +++ b/source/typescript.txt @@ -1,8 +1,9 @@ -.. node-fundamentals-typescript: +.. _node-fundamentals-typescript: +.. _node-typescript: -========== -TypeScript -========== +=================================== +TypeScript Features and Limitations +=================================== .. facet:: :name: genre @@ -203,7 +204,7 @@ To learn more about the limitations of dot notation in the :ref:`` section. -.. typescript-working-with-id: +.. _node-typescript-working-with-id: Working with the _id Field -------------------------- diff --git a/source/usage-examples.txt b/source/usage-examples.txt index 7b44da38d..9bea8f729 100644 --- a/source/usage-examples.txt +++ b/source/usage-examples.txt @@ -24,10 +24,8 @@ Usage Examples Insert Update & Replace Delete - Count Documents Distinct Field Values Run a Command - Watch for Changes Bulk Operations Perform a Transaction