Skip to content

DOCSP-20584: versioned API renamed to stable API #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/redirects
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
define: prefix drivers/node
define: base https://docs.mongodb.com/${prefix}
define: versions v3.6 master
define: versions v3.6 v3.7 v4.0 v4.1 v4.2 v4.3 master

raw: ${prefix}/ -> ${base}/current/
raw: ${prefix}/stable -> ${base}/current/

[*-master]: ${prefix}/${version}/fundamentals/versioned-api/ -> ${prefix}/${version}/fundamentals/stable-api/
1 change: 1 addition & 0 deletions snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ mongosh = "``mongosh``"
driver = "node"
driver-long = "MongoDB Node.js driver"
driver-short = "Node.js driver"
stable-api = "Stable API"
2 changes: 1 addition & 1 deletion source/fundamentals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Fundamentals
.. toctree::

/fundamentals/connection
/fundamentals/versioned-api
/fundamentals/stable-api
/fundamentals/authentication
/fundamentals/crud
/fundamentals/promises
Expand Down
2 changes: 1 addition & 1 deletion source/fundamentals/connection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ URI to specify the behavior of the client.
- string *or* enum
- ``null``
- Specifies the API version that operations must conform to. See the
MongoDB manual entry on :manual:`Versioned API </reference/versioned-api/>`
MongoDB manual entry on :manual:`Stable API </reference/stable-api>`
for more information.

* - **srvMaxHosts**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
=============
Versioned API
=============
.. _nodejs-stable-api:

==============
{+stable-api+}
==============

.. default-domain:: mongodb

Expand All @@ -12,60 +14,62 @@ Versioned API

.. note::

The Versioned API feature requires MongoDB Server 5.0 or later.
The {+stable-api+} feature requires MongoDB Server 5.0 or later.

You should only use the Versioned API feature if all the MongoDB
You should only use the {+stable-api+} feature if all the MongoDB
servers you are connecting to support this feature.

Overview
--------

In this guide, you can learn how to specify the **Versioned API** when connecting to
a MongoDB instance or replica set. You can use the Versioned API feature to
force the server to run operations with behavior compatible with the
specified **API version**. An API version defines the expected behavior of the
operations it covers and the format of server responses. If you change to
a different API version, the operations are not guaranteed to be
compatible and the server responses are not guaranteed to be similar.
In this guide, you can learn how to specify the **{+stable-api+}** when
connecting to a MongoDB instance or replica set. You can use the
{+stable-api+} feature to force the server to run operations with behavior
compatible with the specified **API version**. An API version defines the
expected behavior of the operations it covers and the format of server
responses. If you change to a different API version, the operations are not
guaranteed to be compatible and the server responses are not guaranteed to
be similar.

When you use the Versioned API feature with an official MongoDB driver, you
When you use the {+stable-api+} feature with an official MongoDB driver, you
can update your driver or server without worrying about backward compatibility
issues of the commands covered by the Versioned API.
issues of the commands covered by the {+stable-api+}.

See the server manual page on the `Versioned API <https://docs.mongodb.com/v5.0/reference/versioned-api/>`__
See the MongoDB reference page on the :manual:`{+stable-api+} </reference/stable-api/>`
for more information including a list of commands it covers.

The following sections describe how you can enable the Versioned API for
The following sections describe how you can enable the {+stable-api+} for
your MongoDB client and the options that you can specify.

Enable the Versioned API on a MongoDB Client
--------------------------------------------
Enable the {+stable-api+} on a MongoDB Client
---------------------------------------------

To enable the Versioned API, you must specify an API version in the ``MongoClientOptions``
To enable the {+stable-api+}, you must specify an API version in the ``MongoClientOptions``
passed to your ``MongoClient``. Once you instantiate a ``MongoClient`` instance with
a specified API version, all commands you run with that client use that
version of the Versioned API.
version of the {+stable-api+}.

.. tip::

If you need to run commands using more than one version of the Versioned
API, instantiate a separate client with that version.

If you need to run commands not covered by the Versioned API, make sure the
If you need to run commands not covered by the {+stable-api+}, make sure the
"strict" option is disabled. See the section on
:ref:`Versioned API Options <versioned-api-options>` for more information.
:ref:`{+stable-api+} Options <nodejs-stable-api-options>` for more
information.

The example below shows how you can instantiate a ``MongoClient`` that
sets the Versioned API version and connects to a server by performing the
sets the {+stable-api+} version and connects to a server by performing the
following operations:

- Specify a server URI to connect to.
- Specify a Versioned API version in the ``MongoClientOptions`` object, using a
- Specify a {+stable-api+} version in the ``MongoClientOptions`` object, using a
constant from the ``ServerApiVersion`` object.
- Instantiate a ``MongoClient``, passing the URI and the ``MongoClientOptions``
to the constructor.

.. literalinclude:: /code-snippets/versioned-api/basic.js
.. literalinclude:: /code-snippets/stable-api/basic.js
:start-after: begin serverApiVersion
:end-before: end serverApiVersion
:language: javascript
Expand All @@ -74,7 +78,7 @@ following operations:
.. warning::

If you specify an API version and connect to a MongoDB server that does
not support the Versioned API, your application may throw an error when
not support the {+stable-api+}, your application may throw an error when
connecting to your MongoDB server with the following text:

.. code-block:: none
Expand All @@ -89,12 +93,13 @@ section, see the following API Documentation:
- `MongoClientOptions <{+api+}/interfaces/MongoClientOptions.html>`__
- `MongoClient <{+api+}/classes/MongoClient.html>`__

.. _nodejs-stable-api-options:
.. _versioned-api-options:

Versioned API Options
---------------------
{+stable-api+} Options
----------------------

You can enable or disable optional behavior related to the Versioned API as
You can enable or disable optional behavior related to the {+stable-api+} as
described in the following table.

.. list-table::
Expand All @@ -106,7 +111,7 @@ described in the following table.
- Description

* - version
- | **Required**. Specifies the version of the Versioned API.
- | **Required**. Specifies the version of the {+stable-api+}.
|
| Default: **null**

Expand All @@ -125,7 +130,7 @@ described in the following table.
The following example shows how you can set the options of the ``ServerApi``
interface.

.. literalinclude:: /code-snippets/versioned-api/options.js
.. literalinclude:: /code-snippets/stable-api/options.js
:start-after: begin serverApiVersion
:end-before: end serverApiVersion
:language: javascript
Expand Down
4 changes: 2 additions & 2 deletions source/includes/fundamentals-sections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Learn how to perform the following tasks using the Node.js driver in the
Fundamentals section:

- :doc:`Connect to MongoDB </fundamentals/connection>`
- :doc:`Use the Versioned API </fundamentals/versioned-api>`
- :doc:`Use the {+stable-api+} </fundamentals/stable-api>`
- :doc:`Authenticate with MongoDB </fundamentals/authentication>`
- :doc:`Read from and Write to MongoDB </fundamentals/crud>`
- :doc:`Access Return Values </fundamentals/promises>`
Expand All @@ -13,6 +13,6 @@ Fundamentals section:
- :doc:`Log Events in the Driver </fundamentals/logging>`
- :doc:`Monitor Driver Events </fundamentals/monitoring>`
- :doc:`Store and Retrieve Large Files in MongoDB </fundamentals/gridfs>`
- :doc:`Create and Query Time Series Collection</fundamentals/time-series>`
- :doc:`Create and Query Time Series Collection </fundamentals/time-series>`
- :doc:`Specify Type Parameters with TypeScript </fundamentals/typescript>`