Skip to content

Commit be115df

Browse files
(DOCS-15272): v5.0 backport for count command in stable API (#1055)
* (DOCS-15272): v5.0 backport for count command in stable API * (DOCS-15272): v5.0 backport for count command in stable API (#1052) * DOCS-15272 addition (#1053) * remove 6.0 ref
1 parent fea74c7 commit be115df

File tree

4 files changed

+153
-113
lines changed

4 files changed

+153
-113
lines changed

source/reference/command/count.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ Definition
158158
:ref:`collStats pipeline stage with the count <collstat-count>`
159159
option.
160160

161+
Stable API Support
162+
------------------
163+
164+
Starting in MongoDB 5.0.9, the ``count`` command is included in
165+
:ref:`Stable API <stable-api>` V1. To use the ``count`` command in the
166+
Stable API, you must connect your driver to a deployment that is running
167+
MongoDB 5.0.9 or greater.
168+
161169
Behavior
162170
--------
163171

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.. _stable-api-changelog:
2+
3+
====================
4+
Stable API Changelog
5+
====================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
This page contains a changelog of the Stable API. The Stable API is
16+
actively being expanded to include new database commands and
17+
functionality.
18+
19+
The database commands included in the Stable API depend on the MongoDB
20+
version you are using. This page describes the MongoDB and Stable API
21+
versions when a database command or specific sub-features of a command
22+
are available.
23+
24+
Database Commands
25+
-----------------
26+
27+
The following table describes:
28+
29+
- The commands included in each version of the Stable API.
30+
31+
- The MongoDB version in which the command was added to the Stable API.
32+
33+
.. list-table::
34+
:header-rows: 1
35+
:stub-columns: 1
36+
:widths: 15 5 10
37+
38+
* - Command
39+
- Stable API Version
40+
- Added to Stable API in MongoDB Version
41+
42+
* - :dbcommand:`count`
43+
- V1
44+
- MongoDB 6.0, 5.0.9
45+
* - :dbcommand:`abortTransaction`
46+
- V1
47+
- MongoDB 5.0
48+
* - :dbcommand:`aggregate` (with limitations) [#stable-api-command-limitations]_
49+
- V1
50+
- MongoDB 5.0
51+
* - :dbcommand:`authenticate`
52+
- V1
53+
- MongoDB 5.0
54+
* - :dbcommand:`collMod`
55+
- V1
56+
- MongoDB 5.0
57+
* - :dbcommand:`commitTransaction`
58+
- V1
59+
- MongoDB 5.0
60+
* - :dbcommand:`create` (with limitations) [#stable-api-command-limitations]_
61+
- V1
62+
- MongoDB 5.0
63+
* - :dbcommand:`createIndexes` (with limitations) [#stable-api-command-limitations]_
64+
- V1
65+
- MongoDB 5.0
66+
* - :dbcommand:`delete`
67+
- V1
68+
- MongoDB 5.0
69+
* - :dbcommand:`drop`
70+
- V1
71+
- MongoDB 5.0
72+
* - :dbcommand:`dropDatabase`
73+
- V1
74+
- MongoDB 5.0
75+
* - :dbcommand:`dropIndexes`
76+
- V1
77+
- MongoDB 5.0
78+
* - :dbcommand:`endSessions`
79+
- V1
80+
- MongoDB 5.0
81+
* - :dbcommand:`explain` [#stable-api-explain]_
82+
- V1
83+
- MongoDB 5.0
84+
* - :dbcommand:`find` (with limitations) [#stable-api-command-limitations]_
85+
- V1
86+
- MongoDB 5.0
87+
* - :dbcommand:`findAndModify`
88+
- V1
89+
- MongoDB 5.0
90+
* - :dbcommand:`getMore`
91+
- V1
92+
- MongoDB 5.0
93+
* - :dbcommand:`insert`
94+
- V1
95+
- MongoDB 5.0
96+
* - :dbcommand:`hello`
97+
- V1
98+
- MongoDB 5.0
99+
* - :dbcommand:`killCursors`
100+
- V1
101+
- MongoDB 5.0
102+
* - :dbcommand:`listCollections`
103+
- V1
104+
- MongoDB 5.0
105+
* - :dbcommand:`listDatabases`
106+
- V1
107+
- MongoDB 5.0
108+
* - :dbcommand:`listIndexes`
109+
- V1
110+
- MongoDB 5.0
111+
* - :dbcommand:`ping`
112+
- V1
113+
- MongoDB 5.0
114+
* - :dbcommand:`refreshSessions`
115+
- V1
116+
- MongoDB 5.0
117+
* - :dbcommand:`update`
118+
- V1
119+
- MongoDB 5.0
120+
121+
.. [#stable-api-command-limitations]
122+
123+
API V1 may not support all available options for these commands.
124+
Refer to the specific command documentation for limitations specific
125+
to API V1.
126+
127+
.. [#stable-api-explain]
128+
129+
MongoDB does not guarantee that the output of the
130+
:dbcommand:`explain` command will conform to the same format in
131+
future API versions.

source/reference/stable-api-reference.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ your application code tries to use commands and behaviors deprecated in
4141
API V1. Once your application tests pass and all deprecation errors
4242
have been fixed, you will be ready to test your application with API
4343
V2.
44-

source/reference/stable-api.txt

Lines changed: 14 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -372,77 +372,14 @@ Stable API, you can redeploy it with the new MongoClient options
372372
and be confident that future server upgrades won't negatively
373373
impact your application.
374374

375-
Example: :dbcommand:`count` Migration
376-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377-
378-
This example shows how to migrate an application that implements the
379-
:dbcommand:`count` command to an alternative method of counting
380-
documents. Since the :dbcommand:`count` command does not belong to the
381-
Stable API, this application cannot use the Stable API until the
382-
:dbcommand:`count` command is removed from the code.
383-
384-
Use the sample code to create a ``sales`` collection in
385-
:binary:`~bin.mongosh`:
386-
387-
.. code-block:: javascript
388-
389-
db.sales.insertMany([
390-
{ "_id" : 1, "item" : "abc", "price" : 10, "quantity" : 2, "date" : ISODate("2021-01-01T08:00:00Z") },
391-
{ "_id" : 2, "item" : "jkl", "price" : 20, "quantity" : 1, "date" : ISODate("2021-02-03T09:00:00Z") },
392-
{ "_id" : 3, "item" : "xyz", "price" : 5, "quantity" : 5, "date" : ISODate("2021-02-03T09:05:00Z") },
393-
{ "_id" : 4, "item" : "abc", "price" : 10, "quantity" : 10, "date" : ISODate("2021-02-15T08:00:00Z") },
394-
{ "_id" : 5, "item" : "xyz", "price" : 5, "quantity" : 10, "date" : ISODate("2021-02-15T09:05:00Z") },
395-
{ "_id" : 6, "item" : "xyz", "price" : 5, "quantity" : 5, "date" : ISODate("2021-02-15T12:05:10Z") },
396-
{ "_id" : 7, "item" : "xyz", "price" : 5, "quantity" : 10, "date" : ISODate("2021-02-15T14:12:12Z") },
397-
{ "_id" : 8, "item" : "abc", "price" : 10, "quantity" : 5, "date" : ISODate("2021-03-16T20:20:13Z") }
398-
])
399-
400-
Stable API Error Response
401-
~~~~~~~~~~~~~~~~~~~~~~~~~
402-
403-
For example, issuing ``db.sales.count()`` results in this error:
404-
405-
.. code-block:: javascript
406-
:copyable: false
407-
408-
{
409-
"ok" : 0,
410-
"errmsg" : "Provided apiStrict:true, but the command count is not in API Version 1",
411-
"code" : 323,
412-
"codeName" : "APIStrictError"
413-
}
414-
415-
However, the :dbcommand:`aggregate` command is
416-
:ref:`in the Stable API <api-v1-command-list>` and can be used to
417-
obtain a count. Use the sample code to obtain a count from the ``sales``
418-
collection in :binary:`~bin.mongosh`:
419-
420-
.. code-block:: javascript
421-
422-
db.sales.aggregate([
423-
{
424-
$group: {
425-
_id: null,
426-
count: { $count: { } }
427-
}
428-
}
429-
])
430-
431-
This results in a document where the ``count`` field contains the
432-
number of documents in the collection:
433-
434-
.. code-block:: javascript
435-
436-
{ "_id" : null, "count" : 8 }
437-
438375
How To Use Commands and Features Outside of the Stable API
439376
----------------------------------------------------------
440377

441378
To use commands and features outside of the Stable API, you can
442379
connect to your deployment with a *non-strict* client. By default,
443380
clients are *non-strict*.
444381

445-
Use the sample code to create a *non-strict* client:
382+
To create a *non-strict* client, use the following sample code:
446383

447384
.. tabs-drivers::
448385

@@ -571,8 +508,8 @@ Use the sample code to create a *non-strict* client:
571508
:end-before: End Versioned API Example 3
572509

573510
Using this non-strict client allows you to run commands outside of the
574-
Stable API. For example, this non-strict client now allows you to
575-
use the :dbcommand:`count` command once again.
511+
Stable API. For example, this non-strict client allows you to run the
512+
:dbcommand:`createUser` command.
576513

577514
.. important::
578515

@@ -581,49 +518,13 @@ use the :dbcommand:`count` command once again.
581518

582519
.. _api-v1-command-list:
583520

584-
API V1 Commands
585-
---------------
586-
587-
API V1 protects you from API-breaking changes
588-
for the following commands:
589-
590-
- :dbcommand:`abortTransaction`
591-
- :dbcommand:`aggregate` (with limitations) [#stable-api-command-limitations]_
592-
- :dbcommand:`authenticate`
593-
- :dbcommand:`collMod`
594-
- :dbcommand:`commitTransaction`
595-
- :dbcommand:`create` (with limitations) [#stable-api-command-limitations]_
596-
- :dbcommand:`createIndexes` (with limitations) [#stable-api-command-limitations]_
597-
- :dbcommand:`delete`
598-
- :dbcommand:`drop`
599-
- :dbcommand:`dropDatabase`
600-
- :dbcommand:`dropIndexes`
601-
- :dbcommand:`endSessions`
602-
- :dbcommand:`explain` (with limitations) [#stable-api-explain]_
603-
- :dbcommand:`find` (with limitations) [#stable-api-command-limitations]_
604-
- :dbcommand:`findAndModify`
605-
- :dbcommand:`getMore`
606-
- :dbcommand:`insert`
607-
- :dbcommand:`hello`
608-
- :dbcommand:`killCursors`
609-
- :dbcommand:`listCollections`
610-
- :dbcommand:`listDatabases`
611-
- :dbcommand:`listIndexes`
612-
- :dbcommand:`ping`
613-
- :dbcommand:`refreshSessions`
614-
- :dbcommand:`update`
615-
616-
.. [#stable-api-command-limitations]
617-
618-
API V1 may not support all available options for these commands.
619-
Refer to the specific command documentation for limitations specific
620-
to API V1.
621-
622-
.. [#stable-api-explain]
623-
624-
MongoDB does not guarantee that the output of the
625-
:dbcommand:`explain` command will conform to the same format in
626-
future API versions.
521+
Stable API Commands
522+
-------------------
523+
524+
The database commands included in Stable API V1 depend on the MongoDB
525+
version you are using. To view the database commands included in the
526+
Stable API and the MongoDB version they were introduced, see
527+
:ref:`stable-api-changelog`.
627528

628529
Parameters
629530
----------
@@ -695,8 +596,8 @@ ignored.
695596

696597
.. _api-error-responses:
697598

698-
API Error Responses
699-
~~~~~~~~~~~~~~~~~~~
599+
Stable API Error Responses
600+
--------------------------
700601

701602
This table shows error responses for problematic Stable API requests.
702603

@@ -742,4 +643,5 @@ This table shows error responses for problematic Stable API requests.
742643
:titlesonly:
743644
:hidden:
744645

745-
/reference/stable-api-reference
646+
/reference/stable-api-reference
647+
/reference/stable-api-changelog

0 commit comments

Comments
 (0)