diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index daab1e6c..7fe5d675 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,7 +3,9 @@ [PR Reviewing Guidelines](https://github.com/mongodb/docs-golang/blob/master/REVIEWING.md) JIRA - -Staging - + +### Staging Links + ## Self-Review Checklist diff --git a/.github/workflows/add-netlify-links.yml b/.github/workflows/add-netlify-links.yml new file mode 100644 index 00000000..01bb48bc --- /dev/null +++ b/.github/workflows/add-netlify-links.yml @@ -0,0 +1,58 @@ +name: Add Netlify Links To Changed Pages +on: + workflow_call: + pull_request_target: +jobs: + get-pr-changes: + name: Get Changed Files & Update PR Description + runs-on: ubuntu-latest + permissions: + issues: write + contents: write + pull-requests: write + repository-projects: write + steps: + - uses: actions/checkout@v4 + - name: Get Changed Files + id: changed-files + # pin to a specific commit to ensure stability + uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c + with: + separator: "," + files: source/** + - name: Build Netlify Links for Changed Pages + id: build_page_links + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + new_links="" + base_link='https://deploy-preview-${{ github.event.number }}--docs-golang.netlify.app' + files=$(echo "$CHANGED_FILES" | tr "," "\n") + for file in $files; do + echo "processing ${file}" + if (! grep -s "includes/" <<< "$file") && + (! grep -s "images/" <<< "$file") && + (! grep -s "examples/" <<< "$file"); then + file="${file#source}" + file="${file%.txt}" + filenoslash="${file:1}" + echo "${base_link}${file}" + new_links+="
  • ${filenoslash}
  • " + else + echo "(file skipped)" + fi + done + if [ "$new_links" == "" ]; then + new_links="No pages to preview" + fi + echo "Final new_links string: " + echo "${new_links}" + echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT" + - name: Update the PR Description + uses: MongoCaleb/pr-description-action@master + with: + regex: ".*" + appendContentOnMatchOnly: true + regexFlags: is + content: "\n${{ steps.build_page_links.outputs.staging_links }}\n" + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/snooty.toml b/snooty.toml index 12ebd493..d426336c 100644 --- a/snooty.toml +++ b/snooty.toml @@ -21,8 +21,8 @@ api-version = "v2" driver-long = "MongoDB Go Driver" driver-short = "Go driver" docs-branch = "master" -version = "v2.1" -full-version = "{+version+}.0" +version = "v2.2" +full-version = "{+version+}.1" example = "https://raw.githubusercontent.com/mongodb/docs-golang/{+docs-branch+}/source/includes/usage-examples/code-snippets" api = "https://pkg.go.dev/go.mongodb.org/mongo-driver/{+api-version+}" stable-api = "Stable API" diff --git a/source/archive-reference-files/fundamentals/auth.txt b/source/archive-reference-files/fundamentals/auth.txt index eda165ad..967f6bd9 100644 --- a/source/archive-reference-files/fundamentals/auth.txt +++ b/source/archive-reference-files/fundamentals/auth.txt @@ -33,7 +33,6 @@ The Go driver supports the following authentication mechanisms: * :ref:`SCRAM-SHA-256 ` * :ref:`SCRAM-SHA-1 ` -* :ref:`MONGODB-CR ` * :ref:`MongoDB-AWS ` * :ref:`X.509 ` @@ -63,33 +62,17 @@ Each authentication mechanism contains the following placeholders: authentication data. If you omit this option, the driver uses the default value ``admin``. +.. _golang_sha_256: .. _golang-default-auth-mechanism: -Default -~~~~~~~ - -The default mechanism uses one of the following authentication -mechanisms depending on what MongoDB versions your server supports: - -.. list-table:: - :header-rows: 1 - :stub-columns: 1 - :class: compatibility-large - - * - Mechanism - - Versions - - * - ``SCRAM-SHA-256`` - - MongoDB 4.0 and later - - * - ``SCRAM-SHA-1`` - - MongoDB 3.0, 3.2, 3.4, and 3.6 +``SCRAM-SHA-256`` +~~~~~~~~~~~~~~~~~ - * - ``MONGODB-CR`` - - MongoDB 2.6 and earlier +``SCRAM-SHA-256`` is a salted challenge-response authentication mechanism +(SCRAM) that uses your database username and password, encrypted with the ``SHA-256`` +algorithm, to authenticate your user. This is the default authentication mechanism. -To specify the default authentication mechanism, omit the -``AuthMechanism`` option: +To specify this default authentication mechanism, omit the ``AuthMechanism`` option: .. code-block:: go @@ -103,26 +86,8 @@ To specify the default authentication mechanism, omit the client, err := mongo.Connect(clientOpts) -To learn more about the challenge-response (CR) and salted -challenge-response authentication mechanisms (SCRAM) that MongoDB supports, -see the :manual:`SCRAM ` section of the server manual. - -.. _golang_sha_256: - -``SCRAM-SHA-256`` -~~~~~~~~~~~~~~~~~ - -.. important:: - - ``SCRAM-SHA-256`` is the default authentication method for MongoDB starting - in MongoDB 4.0. - -``SCRAM-SHA-256`` is a salted challenge-response authentication mechanism -(SCRAM) that uses your database username and password, encrypted with the ``SHA-256`` -algorithm, to authenticate your user. - -To specify the ``SCRAM-SHA-256`` authentication mechanism, assign the -``AuthMechanism`` option the value ``"SCRAM-SHA-256"``: +You can also explicitly specify the ``SCRAM-SHA-256`` authentication mechanism +by assigning the ``AuthMechanism`` option the value ``"SCRAM-SHA-256"``: .. code-block:: go :emphasize-lines: 2 @@ -138,17 +103,15 @@ To specify the ``SCRAM-SHA-256`` authentication mechanism, assign the client, err := mongo.Connect(clientOpts) +To learn more about the challenge-response authentication mechanisms (SCRAM) that MongoDB supports, +see the :manual:`SCRAM ` section of the Server manual. + .. _golang-scram-sha-1-auth-mechanism: .. _golang-sha-1: ``SCRAM-SHA-1`` ~~~~~~~~~~~~~~~ -.. important:: - - ``SCRAM-SHA-1`` is the default authentication method for MongoDB versions - 3.0, 3.2, 3.4, and 3.6. - ``SCRAM-SHA-1`` is a salted challenge-response mechanism (SCRAM) that uses your username and password, encrypted using the ``SHA-1`` algorithm, to authenticate your user. @@ -170,29 +133,11 @@ To specify the ``SCRAM-SHA-1`` authentication mechanism, assign the client, err := mongo.Connect(clientOpts) -.. _golang-mongodb-cr: - -``MONGODB-CR`` -~~~~~~~~~~~~~~ - -``MONGODB-CR`` is a challenge-response authentication mechanism that uses your -username and password to authenticate your user. - -.. important:: - - This authentication mechanism was deprecated starting in MongoDB 3.6 - and is no longer supported as of MongoDB 4.0. - .. _golang-mongodb-aws: ``MONGODB-AWS`` ~~~~~~~~~~~~~~~ -.. important:: - - The MONGODB-AWS authentication mechanism is available only in MongoDB - versions 4.4 and later. - The ``MONGODB-AWS`` authentication mechanism uses your Amazon Web Services Identity and Access Management (AWS IAM) credentials to authenticate your user. diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt b/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt index 9458460f..4f034496 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt @@ -7,8 +7,6 @@ Skip Returned Results .. meta:: :description: Learn how to skip a specified number of results in MongoDB read operations using the setSkip() method or the $skip stage in aggregation pipelines. -.. default-domain:: mongodb - .. contents:: On this page :local: :backlinks: none diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt b/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt index a3fba2c5..1344ac59 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt @@ -7,8 +7,6 @@ Sort Results .. meta:: :description: Learn how to sort query results, handle ties, and apply sorting in aggregation pipelines with the MongoDB Go Driver. -.. default-domain:: mongodb - .. contents:: On this page :local: :backlinks: none @@ -286,4 +284,4 @@ guide, see the following API Documentation: - `FindOneAndDelete() <{+api+}/mongo#Collection.FindOneAndDelete>`__ - `FindOneAndUpdate() <{+api+}/mongo#Collection.FindOneAndUpdate>`__ - `FindOneAndReplace() <{+api+}/mongo#Collection.FindOneAndReplace>`__ -- `GridFSBucket.Find() <{+api+}/mongo#GridFSBucket.Find>`__ \ No newline at end of file +- `GridFSBucket.Find() <{+api+}/mongo#GridFSBucket.Find>`__ diff --git a/source/archive-reference-files/usage-examples/command.txt b/source/archive-reference-files/usage-examples/command.txt index 82bcecce..5ad0d725 100644 --- a/source/archive-reference-files/usage-examples/command.txt +++ b/source/archive-reference-files/usage-examples/command.txt @@ -7,8 +7,6 @@ Run a Command Example .. meta:: :description: Learn how to execute commands on a MongoDB server using the runCommand() method in Go, with an example retrieving database statistics. -.. default-domain:: mongodb - You can run commands directly on your MongoDB server by using the ``RunCommand()`` method. diff --git a/source/archive-reference-files/usage-examples/deleteMany.txt b/source/archive-reference-files/usage-examples/deleteMany.txt index 05984844..788d4e9e 100644 --- a/source/archive-reference-files/usage-examples/deleteMany.txt +++ b/source/archive-reference-files/usage-examples/deleteMany.txt @@ -5,9 +5,7 @@ Delete Multiple Documents ========================= .. meta:: - :description: Learn how to delete multiple documents from a collection using the deleteMany() method in the MongoDB Go Driver. - -.. default-domain:: mongodb + :description: Learn how to delete multiple documents from a collection using the DeleteMany() method in the MongoDB Go Driver. You can delete multiple documents in a collection by using the ``DeleteMany()`` method. diff --git a/source/archive-reference-files/usage-examples/deleteOne.txt b/source/archive-reference-files/usage-examples/deleteOne.txt index bd0baba3..46f29095 100644 --- a/source/archive-reference-files/usage-examples/deleteOne.txt +++ b/source/archive-reference-files/usage-examples/deleteOne.txt @@ -5,7 +5,7 @@ Delete a Document ================= .. meta:: - :description: Learn how to delete a document from a collection using the deleteOne() method in the MongoDB Go Driver. + :description: Learn how to delete a document from a collection using the DeleteOne() method in the MongoDB Go Driver. You can delete a document in a collection by using the ``DeleteOne()`` method. diff --git a/source/archive-reference-files/usage-examples/findOne.txt b/source/archive-reference-files/usage-examples/findOne.txt index 4d0e9737..9bceaf84 100644 --- a/source/archive-reference-files/usage-examples/findOne.txt +++ b/source/archive-reference-files/usage-examples/findOne.txt @@ -5,9 +5,7 @@ Find a Document =============== .. meta:: - :description: Retrieve a single document from a collection using the findOne() method in the MongoDB Go Driver. - -.. default-domain:: mongodb + :description: Retrieve a single document from a collection using the FindOne() method in the MongoDB Go Driver. You can retrieve a single document from a collection by using the ``FindOne()`` method. diff --git a/source/archive-reference-files/usage-examples/insertMany.txt b/source/archive-reference-files/usage-examples/insertMany.txt index 87550ff9..1a63c443 100644 --- a/source/archive-reference-files/usage-examples/insertMany.txt +++ b/source/archive-reference-files/usage-examples/insertMany.txt @@ -5,9 +5,7 @@ Insert Multiple Documents ========================= .. meta:: - :description: Learn how to insert multiple documents into a collection using the insertMany() method in the MongoDB Go Driver. - -.. default-domain:: mongodb + :description: Learn how to insert multiple documents into a collection using the InsertMany() method in the MongoDB Go Driver. You can insert multiple documents into a collection by using the ``InsertMany()`` method. diff --git a/source/archive-reference-files/usage-examples/insertOne.txt b/source/archive-reference-files/usage-examples/insertOne.txt index 25cae79e..827d2d06 100644 --- a/source/archive-reference-files/usage-examples/insertOne.txt +++ b/source/archive-reference-files/usage-examples/insertOne.txt @@ -5,9 +5,7 @@ Insert a Document Example ========================= .. meta:: - :description: Learn how to insert a document into a collection using the insertOne() method in the MongoDB Go Driver. - -.. default-domain:: mongodb + :description: Learn how to insert a document into a collection using the InsertOne() method in the MongoDB Go Driver. You can insert a document into a collection by using the ``InsertOne()`` method. diff --git a/source/archive-reference-files/usage-examples/replaceOne.txt b/source/archive-reference-files/usage-examples/replaceOne.txt index 953dc92a..087887b3 100644 --- a/source/archive-reference-files/usage-examples/replaceOne.txt +++ b/source/archive-reference-files/usage-examples/replaceOne.txt @@ -5,9 +5,7 @@ Replace a Document ================== .. meta:: - :description: Learn how to replace a document in a MongoDB collection using the replaceOne() method with the MongoDB Go Driver. - -.. default-domain:: mongodb + :description: Learn how to replace a document in a MongoDB collection using the ReplaceOne() method with the MongoDB Go Driver. You can replace a document in a collection by using the ``ReplaceOne()`` method. diff --git a/source/archive-reference-files/usage-examples/updateMany.txt b/source/archive-reference-files/usage-examples/updateMany.txt index eb2a2e4f..b4b1e7d3 100644 --- a/source/archive-reference-files/usage-examples/updateMany.txt +++ b/source/archive-reference-files/usage-examples/updateMany.txt @@ -5,7 +5,7 @@ Update Multiple Documents ========================= .. meta:: - :description: Learn how to update multiple documents in a collection using the updateMany() method in the MongoDB Go Driver. + :description: Learn how to update multiple documents in a collection using the UpdateMany() method in the MongoDB Go Driver. You can update multiple documents in a collection by using the ``UpdateMany()`` method. diff --git a/source/archive-reference-files/usage-examples/updateOne.txt b/source/archive-reference-files/usage-examples/updateOne.txt index 919fb98c..3b54bdc9 100644 --- a/source/archive-reference-files/usage-examples/updateOne.txt +++ b/source/archive-reference-files/usage-examples/updateOne.txt @@ -5,7 +5,7 @@ Update a Document ================= .. meta:: - :description: Learn how to update a document in a collection using the updateOne() method in the MongoDB Go Driver. + :description: Learn how to update a document in a collection using the UpdateOne() method in the MongoDB Go Driver. You can update a document in a collection by using the ``UpdateOne()`` method. diff --git a/source/connect/connection-options/network-compression.txt b/source/connect/connection-options/network-compression.txt index ae9285ae..c0dad717 100644 --- a/source/connect/connection-options/network-compression.txt +++ b/source/connect/connection-options/network-compression.txt @@ -23,11 +23,11 @@ your application. The {+driver-short+} supports the following compression algorithms: -1. `Snappy `__: available in MongoDB 3.4 and later. +1. `Snappy `__ -2. `Zlib `__: available in MongoDB 3.6 and later. +#. `Zlib `__ -3. `Zstandard `__: available in MongoDB 4.2 and later. +#. `Zstandard `__ If you specify multiple compression algorithms, the driver selects the first one in the list supported by your MongoDB deployment. diff --git a/source/connect/connection-options/stable-api.txt b/source/connect/connection-options/stable-api.txt index 46b853b8..7d56cc11 100644 --- a/source/connect/connection-options/stable-api.txt +++ b/source/connect/connection-options/stable-api.txt @@ -7,8 +7,6 @@ .. meta:: :description: Learn how to specify Stable API compatibility in the MongoDB Go Driver to ensure operations align with a defined API version. -.. default-domain:: mongodb - .. contents:: On this page :local: :backlinks: none @@ -152,4 +150,4 @@ API Documentation: - `ServerAPIOptions <{+api+}/mongo/options#ServerAPIOptions>`__ - `ServerApiVersion <{+api+}/mongo/options#ServerAPIVersion>`__ - `SetDeprecationErrors() <{+api+}/mongo/options#ServerAPIOptions.SetDeprecationErrors>`__ -- `SetStrict() <{+api+}/mongo/options#ServerAPIOptions.SetStrict>`__ \ No newline at end of file +- `SetStrict() <{+api+}/mongo/options#ServerAPIOptions.SetStrict>`__ diff --git a/source/connect/connection-targets.txt b/source/connect/connection-targets.txt index 88c5ae10..38e014c3 100644 --- a/source/connect/connection-targets.txt +++ b/source/connect/connection-targets.txt @@ -13,4 +13,117 @@ Choose a Connection Target :depth: 2 :class: singlecol -.. TODO \ No newline at end of file +Overview +-------- + +In this guide, you can learn how to use a connection string and a ``MongoClient`` +object to connect to different types of MongoDB deployments by using the Go driver. + +.. tip:: + + To see how to create and configure your ``MongoClient`` object, see the :ref:`Create a Mongo Client ` page. + +.. _go-atlas-connection-target: + +Connect to Atlas +---------------- + +To connect to a MongoDB deployment on Atlas, include the following elements +in your connection string: + +- URL of your Atlas cluster +- MongoDB username +- MongoDB password + +Then, pass your connection string to the ``MongoClient`` constructor. + +When you connect to Atlas, we recommend using the {+stable-api+} client option to avoid +breaking changes when Atlas upgrades to a new version of {+mdb-server+}. +To learn more about the {+stable-api+} feature, see the :ref:`` +guide. + +The following code shows how you can create a client that uses an Atlas +connection string and the {+stable-api+} version, connect to MongoDB, and +verify that the connection is successful: + +.. _go-connection-example-code: + +.. literalinclude:: /includes/fundamentals/code-snippets/srv.go + :language: go + +.. important:: + + New Serverless instances can no longer be created, and as of May 5 2025, all + existing Serverless instances will be migrated. The `All Clusters + `__ page in the Atlas UI shows which tiers + your instances will be migrated to, based on usage. See the :ref:`Manage + Serverless Instances ` page to learn more about + how to manually handle existing Serverless instances. + +.. _go-local-connection-target: + +Connect to Local Deployments +---------------------------- + +.. include:: /includes/localhost-connection.rst + +To test whether you can connect to your server, replace the connection +string with your localhost connection string in the preceding :ref:`code example +`. + +.. _go-replica-set-connection-target: + +Connect to Replica Sets +----------------------- + +A MongoDB replica set deployment is a group of connected instances that +store the same set of data. This configuration provides data +redundancy and high data availability. + +To connect to a replica set deployment, specify the hostname and port numbers +of each instance, separated by commas, and the replica set name as the value +of the ``replicaSet`` parameter in the connection string. In the following +example, the hostnames are ``host1``, ``host2``, and ``host3``, and the +port numbers are all ``27017``. The replica set name is ``myRS``. + +.. code-block:: none + + mongodb://host1:27017,host2:27017,host3:27017/?replicaSet=myRS + +When connecting to a replica set, the driver takes the following actions by default: + +- Discovers all replica set members when given the address of any one member. +- Dispatches operations to the appropriate member, such as instructions + to write against the **primary**. + +.. tip:: + + You can specify just one host to connect to a replica set. + However, to ensure connectivity when the specified host + is unavailable, you should provide the full list of hosts. + +.. _go-direct-connection-target: + +Direct Connection +~~~~~~~~~~~~~~~~~ + +To force operations on the host designated in the connection URI, +specify the ``directConnection`` option. Direct connections exhibit the +following behavior: + +- They don't support SRV strings. +- They fail on writes when the specified host is not the **primary**. +- They require you to specify a **secondary** node with :ref:`secondary read + preference ` when the specified host isn't the + **primary** node. + +.. note:: Replica Set in Docker + + .. sharedinclude:: dbx/docker-replica-set.rst + +API Documentation +----------------- + +To learn more about connecting to different MongoDB instances with a +``MongoClient``, see the `MongoClient API +Documentation `__. diff --git a/source/crud/bulk.txt b/source/crud/bulk.txt index 9f79301e..30782fb7 100644 --- a/source/crud/bulk.txt +++ b/source/crud/bulk.txt @@ -7,8 +7,6 @@ Bulk Operations .. meta:: :description: Learn to perform bulk write operations with the MongoDB Go Driver, including inserts, updates, replacements, and deletions, using the bulkWrite() method. -.. default-domain:: mongodb - .. contents:: On this page :local: :backlinks: none @@ -789,4 +787,5 @@ see the following API documentation: - `NewClientUpdateOneModel() <{+api+}/mongo#NewClientUpdateOneModel>`__ - `NewClientUpdateManyModel() <{+api+}/mongo#NewClientUpdateManyModel>`__ - `NewClientDeleteOneModel() <{+api+}/mongo#NewClientDeleteOneModel>`__ -- `NewClientDeleteManyModel() <{+api+}/mongo#NewClientDeleteManyModel>`__ \ No newline at end of file +- `NewClientDeleteManyModel() + <{+api+}/mongo#NewClientDeleteManyModel>`__ diff --git a/source/crud/compound-operations.txt b/source/crud/compound-operations.txt index e2a95cb8..652b05bd 100644 --- a/source/crud/compound-operations.txt +++ b/source/crud/compound-operations.txt @@ -7,8 +7,6 @@ Compound Operations .. meta:: :description: Learn how to perform compound operations in MongoDB using Go, combining read and write actions into a single atomic operation to prevent data alteration. -.. default-domain:: mongodb - .. contents:: On this page :local: :backlinks: none @@ -78,22 +76,22 @@ the specified query filter and deletes it. The method returns a The ``FindOneAndDelete()`` method is an atomic operation, which means it prevents any other write operations from changing the matching document until it - completes. The ``deleteOne()`` method is also an atomic operation, but differs from + completes. The ``DeleteOne()`` method is also an atomic operation, but differs from ``FindOneAndDelete()`` in that you cannot specify a sort order for the matched documents. To find a document and delete it in separate operations, call the - ``findOne()`` method followed by the ``deleteOne()`` method. + ``FindOne()`` method followed by the ``DeleteOne()`` method. Modify Behavior ~~~~~~~~~~~~~~~ You can modify the behavior of the ``FindOneAndDelete()`` method by -passing in a ``FineOneAndDeleteOptions``. If you don't specify a -``FineOneAndDeleteOptions``, the driver uses the default values for each +passing in a ``FindOneAndDeleteOptions``. If you don't specify a +``FindOneAndDeleteOptions``, the driver uses the default values for each option. -The ``FineOneAndDeleteOptions`` type allows you to configure options +The ``FindOneAndDeleteOptions`` type allows you to configure options with the following methods: .. list-table:: @@ -163,22 +161,22 @@ document. The ``FindOneAndUpdate()`` method is an atomic operation, which means it prevents any other write operations from changing the matching document until it - completes. The ``updateOne()`` method is also an atomic operation, but differs from - ``FindOneAndUpdate()`` in that you cannot specify a sort order for the - matched documents. + completes. The ``UpdateOne()`` method is also an atomic operation, but differs from + ``FindOneAndUpdate()`` because you cannot return the pre-image of the + updated document when using ``UpdateOne()``. To find a document and update it in separate operations, call - the ``findOne()`` method followed by the ``updateOne()`` method. + the ``FindOne()`` method followed by the ``UpdateOne()`` method. Modify Behavior ~~~~~~~~~~~~~~~ You can modify the behavior of the ``FindOneAndUpdate()`` method by -passing in a ``FineOneAndUpdateOptions``. If you don't specify a -``FineOneAndUpdateOptions``, the driver uses the default values for each +passing in a ``FindOneAndUpdateOptions``. If you don't specify a +``FindOneAndUpdateOptions``, the driver uses the default values for each option. -The ``FineOneAndUpdateOptions`` type allows you to configure options +The ``FindOneAndUpdateOptions`` type allows you to configure options with the following methods: .. list-table:: @@ -276,11 +274,11 @@ Modify Behavior ~~~~~~~~~~~~~~~ You can modify the behavior of the ``FindOneAndReplace()`` method by -passing in a ``FineOneAndReplaceOptions``. If you don't specify a -``FineOneAndReplaceOptions``, the driver uses the default values for each +passing in a ``FindOneAndReplaceOptions``. If you don't specify a +``FindOneAndReplaceOptions``, the driver uses the default values for each option. -The ``FineOneAndReplaceOptions`` type allows you to configure options +The ``FindOneAndReplaceOptions`` type allows you to configure options with the following methods: .. list-table:: diff --git a/source/crud/delete.txt b/source/crud/delete.txt index aeaecefd..f3078fc1 100644 --- a/source/crud/delete.txt +++ b/source/crud/delete.txt @@ -6,7 +6,7 @@ Delete Documents ================ .. meta:: - :description: Learn how to remove documents from collections with the deleteOne() and deleteMany() methods in the MongoDB Go Driver, with examples and options. + :description: Learn how to remove documents from collections with the DeleteOne() and DeleteMany() methods in the MongoDB Go Driver, with examples and options. .. contents:: On this page :local: diff --git a/source/crud/insert.txt b/source/crud/insert.txt index 581d8326..cd20474d 100644 --- a/source/crud/insert.txt +++ b/source/crud/insert.txt @@ -10,7 +10,7 @@ Insert a Document .. meta:: :keywords: code example, write operation, add data - :description: Learn how to insert documents into a MongoDB collection using the insertOne() and insertMany() methods, with options to modify their behavior. + :description: Learn how to insert documents into a MongoDB collection using the InsertOne() and InsertMany() methods, with options to modify their behavior. .. contents:: On this page :local: diff --git a/source/crud/transactions.txt b/source/crud/transactions.txt index 1b00bc57..c37594c5 100644 --- a/source/crud/transactions.txt +++ b/source/crud/transactions.txt @@ -160,6 +160,14 @@ options, then creates a session with these options: .. sharedinclude:: dbx/transactions-parallelism.rst + .. replacement:: driver-specific-content + + If your application is connected to {+mdb-server+} v8.0 or later, + you can perform write operations on multiple namespaces within a + single transaction by using the client bulk write feature. To + learn more, see the :ref:`golang-bulk-client` section of the Bulk + Operations guide. + Example ------- @@ -211,4 +219,4 @@ guide, see the following API Documentation: - `StartSession() <{+api+}/mongo#Client.StartSession>`__ - `TransactionOptions <{+api+}/mongo/options#TransactionOptions>`__ - `SetWriteConcern() <{+api+}/mongo/options#TransactionOptionsBuilder.SetWriteConcern>`__ -- `InsertMany() <{+api+}/mongo#Collection.InsertMany>`__ \ No newline at end of file +- `InsertMany() <{+api+}/mongo#Collection.InsertMany>`__ diff --git a/source/crud/update.txt b/source/crud/update.txt index bbbb7777..8a133cc6 100644 --- a/source/crud/update.txt +++ b/source/crud/update.txt @@ -11,7 +11,7 @@ Modify Documents .. meta:: :keywords: code example, write operation, change data - :description: Learn how to modify MongoDB documents using update and replace operations, including methods like updateOne(), updateMany(), and replaceOne(). + :description: Learn how to modify MongoDB documents using update and replace operations, including methods like UpdateOne(), UpdateMany(), and ReplaceOne(). .. contents:: On this page :local: @@ -103,9 +103,8 @@ and descriptions `. .. note:: Aggregation Pipelines in Update Operations - If you are using MongoDB Server version 4.2 or later, you can use aggregation - pipelines made up of a subset of aggregation stages in update operations. To learn more about - the aggregation stages MongoDB supports in + You can use aggregation pipelines made up of a subset of aggregation stages + in update operations. To learn more about the aggregation stages MongoDB supports in aggregation pipelines, see our tutorial on performing :manual:`updates with aggregation pipelines `. diff --git a/source/includes/mongodb-compatibility-table-go.rst b/source/includes/mongodb-compatibility-table-go.rst index 3b8a223f..a4c9ec20 100644 --- a/source/includes/mongodb-compatibility-table-go.rst +++ b/source/includes/mongodb-compatibility-table-go.rst @@ -8,54 +8,29 @@ - MongoDB 7.0 - MongoDB 6.1 - MongoDB 6.0 - - MongoDB 5.0 - - MongoDB 4.4 - - MongoDB 4.2 - - MongoDB 4.0 - - MongoDB 3.6 * - 2.2 - ✓ - ✓ - ✓ - ✓ - - ✓ - - ✓ - - ✓ - - ✓ - - ✗ * - 2.1 - ✓ - ✓ - ✓ - ✓ - - ✓ - - ✓ - - ✓ - - ✓ - - ✓ * - 1.12 to 2.0 - ⊛ [#8.0-support]_ - ✓ - ✓ - ✓ - - ✓ - - ✓ - - ✓ - - ✓ - - ✓ * - 1.11 - ⊛ - ⊛ - ✓ - ✓ - - ✓ - - ✓ - - ✓ - - ✓ - - ✓ .. [#8.0-support] {+driver-short+} v1.17 and v2.0 are partially compatible with {+mdb-server+} 8.0 but do not support client bulk write. diff --git a/source/includes/quick-start/atlas-setup.rst b/source/includes/quick-start/atlas-setup.rst index d9ee6259..35cae229 100644 --- a/source/includes/quick-start/atlas-setup.rst +++ b/source/includes/quick-start/atlas-setup.rst @@ -43,26 +43,14 @@ when applicable, and connection options. .. step:: Retrieve your MongoDB Atlas connection string To retrieve your connection string for the cluster you created in the - previous section, log in to your Atlas account. Navigate to the - :guilabel:`Database` section and click :guilabel:`Clusters`. Click the - :guilabel:`Connect` button for the cluster that you want to connect to as - shown below: - - .. figure:: /includes/figures/atlas_connection_select_cluster.png - :alt: Atlas Connection GUI cluster selection screen - - Then, select the :guilabel:`Drivers` option under the :guilabel:`Connect - to your application` header. Select "Go" from the :guilabel:`Driver` - selection menu and the version that best matches the version you installed - from the :guilabel:`Version` selection menu. - - .. step:: Copy your connection string - - Click the button to 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_go.png - :alt: Atlas Connection GUI connection string screen + previous section, do the following: + + 1. Log in to your Atlas account. + 2. Navigate to the :guilabel:`Database` section on the sidebar and select :guilabel:`Clusters`. + 3. Find the cluster you would like to connect to and click the :guilabel:`Connect` button. + 4. Under :guilable:`Connect to your application`, click the :guilabel:`Drivers` option. + 5. Select "Go" from the :guilabel:`Driver` selection menu and the appropriate version from the :guilabel:`Version` selection menu. + 6. Copy the connection string clipboard. .. step:: Update the placeholders @@ -75,6 +63,5 @@ when applicable, and connection options. After completing these steps, you have a connection string that corresponds your Atlas cluster. -To learn more about connecting to the {+driver-long+} through Atlas, see -the :atlas:`Atlas driver connection guide ` -and select **Go** from the :guilabel:`Select your language` dropdown. +To learn more about connecting to Atlas by using the {+driver-long+} and applying +connection options, see the :atlas:`Atlas driver connection guide `. diff --git a/source/indexes.txt b/source/indexes.txt index 92768652..66dcf26d 100644 --- a/source/indexes.txt +++ b/source/indexes.txt @@ -86,8 +86,8 @@ results directly from the index, also called a **covered query**. - ``name`` ascending, ``age`` descending - ``name`` descending, ``age`` ascending - Specifying a sort order of ``name`` and :guilabel:`age` ascending or :guilabel:`name` and ``age`` - descending requires an in-memory sort. + However, specifying a sort order of both fields in the same + direction requires an in-memory sort. To learn how to ensure your index covers your query criteria and projection, see :manual:`Query Coverage diff --git a/source/quick-reference.txt b/source/quick-reference.txt index 93a7cc37..3e98c2ed 100644 --- a/source/quick-reference.txt +++ b/source/quick-reference.txt @@ -7,8 +7,6 @@ Quick Reference .. meta:: :description: Explore with the MongoDB Go Driver syntax for various commands, including find, insert, update, delete, and more, with links to API documentation and usage examples. -.. default-domain:: mongodb - This page shows the driver syntax for several MongoDB commands and links to their related reference and API documentation. diff --git a/source/reference/release-notes.txt b/source/reference/release-notes.txt index 717481e5..783bdbe6 100644 --- a/source/reference/release-notes.txt +++ b/source/reference/release-notes.txt @@ -89,23 +89,23 @@ What's New in 2.1 The 2.1 {+driver-short+} release includes the following improvements and fixes: -- Introduces the new `Client.BulkWrite <{+api+}/mongo#Client.BulkWrite>`__ method, +- Introduces the `Client.BulkWrite <{+api+}/mongo#Client.BulkWrite>`__ method, enabling clients to perform multiple insert, update, and delete operations across multiple databases and collections in a single request. To learn more, see the :ref:`golang-bulk` guide. -- Introduces the new `bson.Vector <{+api+}/bson#Vector>`__ type to make inserting and querying +- Introduces the `bson.Vector <{+api+}/bson#Vector>`__ type to make inserting and querying vector data by using :atlas:`Atlas Vector Search ` - easier and more efficient. For an example using the ``bson.Vector`` type, see - the {+driver-short+}'s :ref:`Atlas Vector Search ` guide. + easier and more efficient. To view an example that uses the ``bson.Vector`` type, see + the :ref:`Atlas Vector Search ` guide. - Extends the `ServerError <{+api+}/mongo#ServerError>`__ interface to include ``ErrorCodes``, which returns a list of deduplicated error codes returned by the server during the lifetime of operation execution. - Adds the ``sort`` option to `UpdateOneOptions <{+api+}/mongo/options#UpdateOneOptions>`__ - and `ReplaceOptions <{+api+}/mongo/options#ReplaceOptions>`__ for the ``updateOne`` - and ``replaceOne`` operations. + and `ReplaceOptions <{+api+}/mongo/options#ReplaceOptions>`__ for + standalone update and replace operations and in bulk operations. For more information about the changes in this version, see the :github:`v2.1 release notes `