Skip to content

Commit e3b7abf

Browse files
authored
Merge pull request #191 from rustagir/DOCSP-44644-dbcoll-accessor-aliases-v1.21
DOCSP-44644: db/coll accessor methods
2 parents 7c13ef6 + 45b9fca commit e3b7abf

11 files changed

+411
-23
lines changed

.github/workflows/vale-tdbx.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,26 @@ jobs:
1212
- name: checkout
1313
uses: actions/checkout@v4
1414

15+
- name: Install docutils
16+
run: sudo apt-get install -y docutils
17+
1518
- id: files
1619
uses: masesgroup/retrieve-changed-files@v2
1720
with:
18-
format: 'csv'
21+
format: "csv"
1922

2023
- name: checkout-latest-rules
2124
uses: actions/checkout@v4
2225
with:
2326
repository: mongodb/mongodb-vale-action
24-
path: './tdbx-vale-rules'
27+
path: "./tdbx-vale-rules"
2528
token: ${{secrets.GITHUB_TOKEN}}
2629

2730
- name: move-files-for-vale-action
2831
run: |
29-
cp tdbx-vale-rules/.vale.ini .vale.ini
30-
mkdir -p .github/styles/
31-
cp -rf tdbx-vale-rules/.github/styles/ .github/
32+
cp tdbx-vale-rules/.vale.ini .vale.ini
33+
mkdir -p .github/styles/
34+
cp -rf tdbx-vale-rules/.github/styles/ .github/
3235
3336
- name: run-vale
3437
uses: errata-ai/vale-action@reviewdog

source/reference/class/MongoDBClient.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
MongoDB\\Client Class
33
=====================
44

5-
.. default-domain:: mongodb
6-
75
.. contents:: On this page
86
:local:
97
:backlinks: none
@@ -33,6 +31,8 @@ Methods
3331
addSubscriber() </reference/method/MongoDBClient-addSubscriber>
3432
createClientEncryption() </reference/method/MongoDBClient-createClientEncryption>
3533
dropDatabase() </reference/method/MongoDBClient-dropDatabase>
34+
getCollection() </reference/method/MongoDBClient-getCollection>
35+
getDatabase() </reference/method/MongoDBClient-getDatabase>
3636
getManager() </reference/method/MongoDBClient-getManager>
3737
getReadConcern() </reference/method/MongoDBClient-getReadConcern>
3838
getReadPreference() </reference/method/MongoDBClient-getReadPreference>
@@ -51,6 +51,8 @@ Methods
5151
- :phpmethod:`MongoDB\Client::addSubscriber()`
5252
- :phpmethod:`MongoDB\Client::createClientEncryption()`
5353
- :phpmethod:`MongoDB\Client::dropDatabase()`
54+
- :phpmethod:`MongoDB\Client::getCollection()`
55+
- :phpmethod:`MongoDB\Client::getDatabase()`
5456
- :phpmethod:`MongoDB\Client::getManager()`
5557
- :phpmethod:`MongoDB\Client::getReadConcern()`
5658
- :phpmethod:`MongoDB\Client::getReadPreference()`

source/reference/class/MongoDBCollection.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Definition
2222
:php:`MongoDB\Driver\Manager <class.mongodb-driver-manager>` class or
2323
select a collection from the library's :phpclass:`MongoDB\Client` or
2424
:phpclass:`MongoDB\Database` classes. A collection may also be cloned from
25-
an existing :phpclass:`MongoDB\Collection` object via the
25+
an existing :phpclass:`MongoDB\Collection` object by using the
2626
:phpmethod:`withOptions() <MongoDB\Collection::withOptions()>` method.
2727

2828
:phpclass:`MongoDB\Collection` supports the :php:`readConcern

source/reference/class/MongoDBDatabase.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
MongoDB\\Database Class
33
=======================
44

5-
.. default-domain:: mongodb
6-
75
.. contents:: On this page
86
:local:
97
:backlinks: none
@@ -22,7 +20,7 @@ Definition
2220
:php:`MongoDB\Driver\Manager <class.mongodb-driver-manager>` class or
2321
select a database from the library's :phpclass:`MongoDB\Client` class. A
2422
database may also be cloned from an existing :phpclass:`MongoDB\Database`
25-
object via the :phpmethod:`withOptions() <MongoDB\Database::withOptions()>`
23+
object by using the :phpmethod:`withOptions() <MongoDB\Database::withOptions()>`
2624
method.
2725

2826
:phpclass:`MongoDB\Database` supports the :php:`readConcern
@@ -51,6 +49,7 @@ Methods
5149
createEncryptedCollection() </reference/method/MongoDBDatabase-createEncryptedCollection>
5250
drop() </reference/method/MongoDBDatabase-drop>
5351
dropCollection() </reference/method/MongoDBDatabase-dropCollection>
52+
getCollection() </reference/method/MongoDBDatabase-getCollection>
5453
getDatabaseName() </reference/method/MongoDBDatabase-getDatabaseName>
5554
getManager() </reference/method/MongoDBDatabase-getManager>
5655
getReadConcern() </reference/method/MongoDBDatabase-getReadConcern>
@@ -75,6 +74,7 @@ Methods
7574
- :phpmethod:`MongoDB\Database::drop()`
7675
- :phpmethod:`MongoDB\Database::dropCollection()`
7776
- :phpmethod:`MongoDB\Database::getDatabaseName()`
77+
- :phpmethod:`MongoDB\Database::getCollection()`
7878
- :phpmethod:`MongoDB\Database::getManager()`
7979
- :phpmethod:`MongoDB\Database::getReadConcern()`
8080
- :phpmethod:`MongoDB\Database::getReadPreference()`
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
================================
2+
MongoDB\\Client::getCollection()
3+
================================
4+
5+
.. contents:: On this page
6+
:local:
7+
:backlinks: none
8+
:depth: 1
9+
:class: singlecol
10+
11+
Definition
12+
----------
13+
14+
.. phpmethod:: MongoDB\Client::getCollection()
15+
16+
Gets access to a collection on the server. This method is an alias for
17+
:phpmethod:`MongoDB\Client::selectCollection()` and will replace it in
18+
a future release.
19+
20+
.. code-block:: php
21+
22+
function getCollection(
23+
string $databaseName,
24+
string $collectionName,
25+
array $options = []
26+
): MongoDB\Collection
27+
28+
Parameters
29+
----------
30+
31+
``$databaseName`` : string
32+
The name of the database containing the collection to access.
33+
34+
``$collectionName`` : string
35+
The name of the collection to access.
36+
37+
``$options`` : array
38+
An array specifying the desired options.
39+
40+
.. list-table::
41+
:header-rows: 1
42+
:widths: 20 20 80
43+
44+
* - Name
45+
- Type
46+
- Description
47+
48+
* - codec
49+
- MongoDB\\Codec\\DocumentCodec
50+
- The default :doc:`codec </data-formats/codecs>` to use for collection
51+
operations.
52+
53+
.. versionadded:: 1.17
54+
55+
* - readConcern
56+
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
57+
- The default read concern to use for collection operations. Defaults to
58+
the client's read concern.
59+
60+
* - readPreference
61+
- :php:`MongoDB\Driver\ReadPreference <class.mongodb-driver-readpreference>`
62+
- The default read preference to use for collection operations. Defaults
63+
to the client's read preference.
64+
65+
* - typeMap
66+
- array
67+
- The default type map to use for collection operations. Defaults to the
68+
client's type map.
69+
70+
* - writeConcern
71+
- :php:`MongoDB\Driver\WriteConcern <class.mongodb-driver-writeconcern>`
72+
- The default write concern to use for collection operations. Defaults to
73+
the client's write concern.
74+
75+
Return Values
76+
-------------
77+
78+
A :phpclass:`MongoDB\Collection` object.
79+
80+
Errors/Exceptions
81+
-----------------
82+
83+
.. include:: /includes/extracts/error-invalidargumentexception.rst
84+
85+
Behavior
86+
--------
87+
88+
The selected collection inherits options such as read preference and type
89+
mapping from the :phpclass:`Client <MongoDB\Client>` object. Options may be
90+
overridden by using the ``$options`` parameter.
91+
92+
Example
93+
-------
94+
95+
The following example gets access to the ``users`` collection in the ``test`` database:
96+
97+
.. code-block:: php
98+
99+
<?php
100+
101+
$client = new MongoDB\Client;
102+
103+
$collection = $client->getCollection('test', 'users');
104+
105+
The following example gets access to the ``users`` collection in the ``test`` database
106+
with a custom read preference:
107+
108+
.. code-block:: php
109+
110+
<?php
111+
112+
$client = new MongoDB\Client;
113+
114+
$collection = $client->getCollection(
115+
'test',
116+
'users',
117+
[
118+
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
119+
]
120+
);
121+
122+
See Also
123+
--------
124+
125+
- :phpmethod:`MongoDB\Collection::__construct()`
126+
- :phpmethod:`MongoDB\Database::getCollection()`
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
==============================
2+
MongoDB\\Client::getDatabase()
3+
==============================
4+
5+
.. contents:: On this page
6+
:local:
7+
:backlinks: none
8+
:depth: 1
9+
:class: singlecol
10+
11+
Definition
12+
----------
13+
14+
.. phpmethod:: MongoDB\Client::getDatabase()
15+
16+
Gets access to a database on the server. This method is an alias for
17+
:phpmethod:`MongoDB\Client::selectDatabase()` and will replace it in
18+
a future release.
19+
20+
.. code-block:: php
21+
22+
function getDatabase(
23+
string $databaseName,
24+
array $options = []
25+
): MongoDB\Database
26+
27+
Parameters
28+
----------
29+
30+
``$databaseName`` : string
31+
The name of the database to access.
32+
33+
``$options`` : array
34+
An array specifying the desired options.
35+
36+
.. list-table::
37+
:header-rows: 1
38+
:widths: 20 20 80
39+
40+
* - Name
41+
- Type
42+
- Description
43+
44+
* - readConcern
45+
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
46+
- The default read concern to use for database operations. Defaults to
47+
the client's read concern.
48+
49+
* - readPreference
50+
- :php:`MongoDB\Driver\ReadPreference <class.mongodb-driver-readpreference>`
51+
- The default read preference to use for database operations. Defaults to
52+
the client's read preference.
53+
54+
* - typeMap
55+
- array
56+
- The default type map to use for database operations. Defaults to the
57+
client's type map.
58+
59+
* - writeConcern
60+
- :php:`MongoDB\Driver\WriteConcern <class.mongodb-driver-writeconcern>`
61+
- The default write concern to use for database operations. Defaults to
62+
the client's write concern.
63+
64+
Return Values
65+
-------------
66+
67+
A :phpclass:`MongoDB\Database` object.
68+
69+
Errors/Exceptions
70+
-----------------
71+
72+
.. include:: /includes/extracts/error-invalidargumentexception.rst
73+
74+
Behavior
75+
--------
76+
77+
The selected database inherits options such as read preference and type mapping
78+
from the :phpclass:`Client <MongoDB\Client>` object. Options may be overridden
79+
by using the ``$options`` parameter.
80+
81+
Example
82+
-------
83+
84+
The following example gets access to the ``test`` database:
85+
86+
.. code-block:: php
87+
88+
<?php
89+
90+
$client = new MongoDB\Client;
91+
92+
$db = $client->getDatabase('test');
93+
94+
The following examples gets access to the ``test`` database with a custom read
95+
preference:
96+
97+
.. code-block:: php
98+
99+
<?php
100+
101+
$client = new MongoDB\Client;
102+
103+
$db = $client->getDatabase(
104+
'test',
105+
[
106+
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
107+
]
108+
);
109+
110+
See Also
111+
--------
112+
113+
- :phpmethod:`MongoDB\Client::__get()`
114+
- :phpmethod:`MongoDB\Database::__construct()`

source/reference/method/MongoDBClient-selectCollection.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
MongoDB\\Client::selectCollection()
33
===================================
44

5-
.. default-domain:: mongodb
6-
75
.. contents:: On this page
86
:local:
97
:backlinks: none
@@ -15,7 +13,9 @@ Definition
1513

1614
.. phpmethod:: MongoDB\Client::selectCollection()
1715

18-
Selects a collection on the server.
16+
Selects a collection on the server. This method is aliased by
17+
:phpmethod:`MongoDB\Client::getCollection()` and will be replaced by
18+
it in a future release.
1919

2020
.. code-block:: php
2121

@@ -87,7 +87,7 @@ Behavior
8787

8888
The selected collection inherits options such as read preference and type
8989
mapping from the :phpclass:`Client <MongoDB\Client>` object. Options may be
90-
overridden via the ``$options`` parameter.
90+
overridden by using the ``$options`` parameter.
9191

9292
Example
9393
-------

0 commit comments

Comments
 (0)