@@ -7,15 +7,15 @@ Mongo()
7
7
.. contents:: On this page
8
8
:local:
9
9
:backlinks: none
10
- :depth: 1
10
+ :depth: 2
11
11
:class: singlecol
12
12
13
13
Description
14
14
-----------
15
15
16
16
.. versionchanged:: 4.2
17
17
18
- .. method:: Mongo(host, {+auto-encrypt-options+})
18
+ .. method:: Mongo(host, {+auto-encrypt-options+}, api )
19
19
20
20
JavaScript constructor to instantiate a database connection from
21
21
:binary:`~bin.mongosh` or from a JavaScript file.
@@ -36,21 +36,19 @@ Description
36
36
37
37
- string
38
38
39
- - Optional. The host, either in the form of ``<host>`` or
39
+ - * Optional* . The host, either in the form of ``<host>`` or
40
40
``<host><:port>``.
41
41
42
42
If omitted, :method:`Mongo` instantiates a connection to the
43
43
localhost interface on the default port ``27017``.
44
44
45
45
* - ``{+auto-encrypt-options+}``
46
46
47
- - Document
47
+ - document
48
48
49
- - *Optional*
50
-
51
- .. versionadded:: 4.2
52
-
53
- Configuration parameters for enabling
49
+ - .. versionadded:: 4.2
50
+
51
+ *Optional*. Configuration parameters for enabling
54
52
:ref:`manual-csfle-feature`.
55
53
56
54
``{+auto-encrypt-options+}`` overrides the
@@ -59,14 +57,22 @@ Description
59
57
inherits the client-side field level encryption configuration
60
58
of the current database connection.
61
59
62
- For documentation of usage and syntax, see
63
- :ref:`{+auto-encrypt-options+}`.
60
+ See :ref:`{+auto-encrypt-options+}` for usage and syntax
61
+ details.
62
+
63
+ * - ``api``
64
+
65
+ - document
66
+
67
+ - *Optional*. Configuration options for enabling the
68
+ :ref:`Stable API <stable-api>`.
69
+
70
+ See :ref:`mongo-api-options` for usage and syntax details.
64
71
65
72
.. seealso::
66
73
67
74
:method:`Mongo.getDB()` and :method:`db.getMongo()`
68
75
69
-
70
76
.. _{+auto-encrypt-options+}:
71
77
72
78
``{+title-auto-encrypt-options+}``
@@ -261,9 +267,32 @@ following parameters:
261
267
indexed fields without the ``crypt_shared`` library. For details,
262
268
see :ref:`qe-reference-mongo-client`.
263
269
264
- Example
270
+
271
+ .. _mongo-api-options:
272
+
273
+ ``api``
265
274
-------
266
275
276
+ The ``api`` parameter specifies configuration options for the
277
+ :ref:`Stable API <stable-api>`. You can enable or disable optional
278
+ behavior using the following options:
279
+
280
+ .. include:: /includes/stable-api-options.rst
281
+
282
+ .. |param| replace:: Option
283
+ .. |apiVersion| replace:: ``version``
284
+ .. |strict| replace:: ``strict``
285
+ .. |deprecation| replace:: ``deprecationErrors``
286
+
287
+ The ``api`` parameter has the following syntax:
288
+
289
+ .. code-block:: javascript
290
+
291
+ { api: { version: <string>, strict: <boolean>, deprecationErrors: <boolean> } }
292
+
293
+ Examples
294
+ --------
295
+
267
296
Connect to a MongoDB Cluster
268
297
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
269
298
@@ -284,8 +313,8 @@ Issue operations against the ``cluster`` object to interact with the
284
313
285
314
.. _mongo-connection-client-side-encryption-enabled:
286
315
287
- Connect to a MongoDB Cluster with Client-Side Encryption Enabled
288
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316
+ Connect to a Cluster with Client-Side Encryption Enabled
317
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289
318
290
319
Configuring client-side field level encryption for a :ref:`locally
291
320
managed key <field-level-encryption-local-kms>` requires specifying a
@@ -345,8 +374,8 @@ a complete list of client-side field level encryption methods.
345
374
346
375
.. _mongo-connection-automatic-client-side-encryption-enabled:
347
376
348
- Connect to a MongoDB Cluster with Automatic Client-Side Encryption Enabled
349
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377
+ Connect to a Cluster with Automatic Client-Side Encryption Enabled
378
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350
379
351
380
Configuring client-side field level encryption for a :ref:`locally
352
381
managed key <field-level-encryption-local-kms>` requires specifying a
@@ -431,3 +460,23 @@ the specified data encryption key can decrypt the field.
431
460
432
461
See :doc:`/reference/method/js-client-side-field-level-encryption` for
433
462
a complete list of client-side field level encryption methods.
463
+
464
+ Connect to a Cluster with the Stable API Enabled
465
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
466
+
467
+ The following operation creates a new connection object from within a
468
+ :binary:`~bin.mongosh` session. The :ref:`mongo-api-options` option
469
+ enables Stable API V1 and specifies that you cannot
470
+ run deprecated command or commands outside of the Stable API.
471
+
472
+ .. code-block:: javascript
473
+
474
+ cluster = Mongo(
475
+ "mongodb://mymongo.example.net:27017/?replicaSet=myMongoCluster",
476
+ null,
477
+ { api: { version: "1", strict: true, deprecationErrors: true } }
478
+ )
479
+
480
+ To interact with the ``mymongo.example.net:27017`` cluster, issue
481
+ operations against the ``cluster`` object. For a full list of Stable API
482
+ commands, see :ref:`<api-v1-command-list>`.
0 commit comments