@@ -15,26 +15,17 @@ Definition
1515
1616.. method:: db.getSiblingDB(<database>)
1717
18-
1918 .. list-table::
2019 :header-rows: 1
2120 :widths: 20 20 80
2221
2322 * - Parameter
24-
2523 - Type
26-
2724 - Description
2825
2926 * - ``database``
30-
3127 - string
32-
3328 - The name of a MongoDB database.
34-
35-
36-
37-
3829
3930 :returns: A database object.
4031
@@ -47,33 +38,49 @@ Example
4738You can use :method:`db.getSiblingDB()` as an alternative to the ``use
4839<database>`` helper. This is particularly useful when writing scripts
4940using :binary:`~bin.mongosh` where the ``use`` helper is not
50- available. Consider the following sequence of operations:
41+ available.
42+
43+ Consider a MongoDB instance with two databases, ``users`` and
44+ ``records``. The ``active`` collection is a part of the ``users``
45+ database. The ``requests`` collection is a part of the ``records``
46+ database.
47+
48+ Specify a Database
49+ ~~~~~~~~~~~~~~~~~~
50+
51+ This operation sets the ``db`` object to point to the database named
52+ ``users``, and then returns a :method:`document count
53+ <db.collection.countDocuments>` for the ``active`` collection.
5154
5255.. code-block:: javascript
5356
5457 db = db.getSiblingDB('users')
55- db.active.count ()
58+ db.active.countDocuments ()
5659
57- This operation sets the ``db`` object to point to the database named
58- ``users``, and then returns a :doc:`count
59- </reference/method/db.collection.count>` of the collection named
60- ``active``. You can create multiple ``db`` objects, that refer to
61- different databases, as in the following sequence of operations:
60+ Use Multiple Databases
61+ ~~~~~~~~~~~~~~~~~~~~~~
62+
63+ You can create multiple ``db`` objects, that refer to different
64+ databases, as in the following sequence of operations:
6265
6366.. code-block:: javascript
6467
6568 users = db.getSiblingDB('users')
6669 records = db.getSiblingDB('records')
6770
68- users.active.count ()
71+ users.active.countDocuments ()
6972 users.active.findOne()
7073
71- records.requests.count ()
74+ records.requests.countDocuments ()
7275 records.requests.findOne()
7376
74- This operation creates two ``db`` objects referring to different
75- databases (i.e. ``users`` and ``records``) and then returns a
76- :doc:`count </reference/method/db.collection.count>` and an
77- :doc:`example document </reference/method/db.collection.findOne>` from
78- one collection in that database (i.e. ``active`` and ``requests``
79- respectively.)
77+ This operation creates two ``db`` objects. Each ``db`` object refers to
78+ a different database, ``users`` or ``records``.
79+
80+ For each database, the query returns:
81+
82+ - a :method:`document count <db.collection.countDocuments>`, and
83+ - an :method:`example document <db.collection.findOne>`
84+
85+ from a collection in that database.
86+
0 commit comments