diff --git a/source/data-formats/modeling-bson-data.txt b/source/data-formats/modeling-bson-data.txt index 7fea0cfa..144790db 100644 --- a/source/data-formats/modeling-bson-data.txt +++ b/source/data-formats/modeling-bson-data.txt @@ -21,7 +21,7 @@ allows control over how BSON is converted to PHP. Additionally, the :phpclass:`MongoDB\Client`, :phpclass:`MongoDB\Database`, and :phpclass:`MongoDB\Collection` classes accept a ``typeMap`` option, which can be used to specify a default type map to apply to any supporting methods and -selected classes (e.g. :phpmethod:`MongoDB\Client::selectDatabase()`). +selected classes (e.g. :phpmethod:`MongoDB\Client::getDatabase()`). The :phpclass:`MongoDB\Client`, :phpclass:`MongoDB\Database`, and :phpclass:`MongoDB\Collection` classes use the following type map by diff --git a/source/databases-collections.txt b/source/databases-collections.txt index 98d09bfe..833a85b9 100644 --- a/source/databases-collections.txt +++ b/source/databases-collections.txt @@ -40,7 +40,7 @@ MongoDB organizes data into a hierarchy of the following levels: Access a Database ----------------- -Access a database by passing the database name to the ``MongoDB\Client::selectDatabase()`` +Access a database by passing the database name to the ``MongoDB\Client::getDatabase()`` method. The following example accesses a database named ``test_database``: @@ -76,12 +76,12 @@ Access a Collection Access a collection by using either of the following methods: -- ``MongoDB\Client::selectCollection()``: Pass the database and collection names as +- ``MongoDB\Client::getCollection()``: Pass the database and collection names as parameters -- ``MongoDB\Database::selectCollection()``: Pass the collection name as a parameter +- ``MongoDB\Database::getCollection()``: Pass the collection name as a parameter The following example accesses a collection named ``test_collection`` by using the -``MongoDB\Database::selectCollection()`` method: +``MongoDB\Database::getCollection()`` method: .. literalinclude:: /includes/databases-collections/databases-collections.php :language: php @@ -198,10 +198,10 @@ by specifying a read preference, read concern, or write concern. By default, databases inherit read and write settings from the ``MongoDB\Client`` instance. Collections inherit these settings from the ``MongoDB\Client`` or -``MongoDB\Database`` instance on which the ``selectCollection()`` method is called. +``MongoDB\Database`` instance on which the ``getCollection()`` method is called. You can change these settings by passing an options array to the -``MongoDB\Client::selectDatabase()``, ``MongoDB\Client::selectCollection()``, or -``MongoDB\Database::selectCollection()`` methods. +``MongoDB\Client::getDatabase()``, ``MongoDB\Client::getCollection()``, or +``MongoDB\Database::getCollection()`` methods. To learn more about setting a read preference, read concern, and write concern, see the :ref:`php-read-write-pref` guide. @@ -212,9 +212,9 @@ API Documentation To learn more about any of the methods or types discussed in this guide, see the following API documentation: -- :phpmethod:`MongoDB\Client::selectDatabase()` -- :phpmethod:`MongoDB\Client::selectCollection()` -- :phpmethod:`MongoDB\Database::selectCollection()` +- :phpmethod:`MongoDB\Client::getDatabase()` +- :phpmethod:`MongoDB\Client::getCollection()` +- :phpmethod:`MongoDB\Database::getCollection()` - :phpmethod:`MongoDB\Database::createCollection()` - :phpmethod:`MongoDB\Database::listCollections()` - :phpmethod:`MongoDB\Database::dropCollection()` diff --git a/source/examples/aws-lambda/index.php b/source/examples/aws-lambda/index.php index caad319b..ba09a098 100644 --- a/source/examples/aws-lambda/index.php +++ b/source/examples/aws-lambda/index.php @@ -9,7 +9,7 @@ try { $client = new Client($uri); $planets = $client - ->selectCollection('sample_guides', 'planets') + ->getCollection('sample_guides', 'planets') ->find([], ['sort' => ['orderFromSun' => 1]]); } catch (Throwable $exception) { exit($exception->getMessage()); diff --git a/source/examples/codecs/handling-documents/using-codec.php b/source/examples/codecs/handling-documents/using-codec.php index 4d05ac29..0c265a39 100644 --- a/source/examples/codecs/handling-documents/using-codec.php +++ b/source/examples/codecs/handling-documents/using-codec.php @@ -3,7 +3,7 @@ use MongoDB\Client; $client = new Client(); -$collection = $client->selectCollection('test', 'person', [ +$collection = $client->getCollection('test', 'person', [ 'codec' => new PersonCodec(), ]); diff --git a/source/examples/encryption/create_data_key.php b/source/examples/encryption/create_data_key.php index 9dd27d72..f863f9c5 100644 --- a/source/examples/encryption/create_data_key.php +++ b/source/examples/encryption/create_data_key.php @@ -17,8 +17,8 @@ /* Prepare the database for this script. Drop the key vault collection and * ensure it has a unique index for keyAltNames. This would typically be done * during application deployment. */ -$client->selectCollection('encryption', '__keyVault')->drop(); -$client->selectCollection('encryption', '__keyVault')->createIndex(['keyAltNames' => 1], [ +$client->getCollection('encryption', '__keyVault')->drop(); +$client->getCollection('encryption', '__keyVault')->createIndex(['keyAltNames' => 1], [ 'unique' => true, 'partialFilterExpression' => ['keyAltNames' => ['$exists' => true]], ]); diff --git a/source/examples/encryption/csfle-automatic_encryption-local_schema.php b/source/examples/encryption/csfle-automatic_encryption-local_schema.php index 42557447..33e88f4f 100644 --- a/source/examples/encryption/csfle-automatic_encryption-local_schema.php +++ b/source/examples/encryption/csfle-automatic_encryption-local_schema.php @@ -63,8 +63,8 @@ * Note: without a server-side schema, another client could potentially insert * unencrypted data into the collection. Therefore, a local schema should always * be used in conjunction with a server-side schema. */ -$encryptedClient->selectDatabase('test')->createCollection('coll', ['validator' => ['$jsonSchema' => $schema]]); -$encryptedCollection = $encryptedClient->selectCollection('test', 'coll'); +$encryptedClient->getDatabase('test')->createCollection('coll', ['validator' => ['$jsonSchema' => $schema]]); +$encryptedCollection = $encryptedClient->getCollection('test', 'coll'); /* Using the encrypted client, insert and find a document to demonstrate that * the encrypted field is automatically encrypted and decrypted. */ @@ -74,7 +74,7 @@ /* Using the client configured without encryption, find the same document and * observe that the field is not automatically decrypted. */ -$unencryptedCollection = $client->selectCollection('test', 'coll'); +$unencryptedCollection = $client->getCollection('test', 'coll'); print_r($unencryptedCollection->findOne(['_id' => 1])); diff --git a/source/examples/encryption/csfle-automatic_encryption-server_side_schema.php b/source/examples/encryption/csfle-automatic_encryption-server_side_schema.php index 44531522..04a35691 100644 --- a/source/examples/encryption/csfle-automatic_encryption-server_side_schema.php +++ b/source/examples/encryption/csfle-automatic_encryption-server_side_schema.php @@ -55,8 +55,8 @@ /* Create a new collection for this script. Configure a server-side schema by * explicitly creating the collection with a "validator" option. */ -$encryptedClient->selectDatabase('test')->createCollection('coll', ['validator' => ['$jsonSchema' => $schema]]); -$encryptedCollection = $encryptedClient->selectCollection('test', 'coll'); +$encryptedClient->getDatabase('test')->createCollection('coll', ['validator' => ['$jsonSchema' => $schema]]); +$encryptedCollection = $encryptedClient->getCollection('test', 'coll'); /* Using the encrypted client, insert and find a document to demonstrate that * the encrypted field is automatically encrypted and decrypted. */ @@ -66,7 +66,7 @@ /* Using the client configured without encryption, find the same document and * observe that the field is not automatically decrypted. */ -$unencryptedCollection = $client->selectCollection('test', 'coll'); +$unencryptedCollection = $client->getCollection('test', 'coll'); print_r($unencryptedCollection->findOne(['_id' => 1])); diff --git a/source/examples/encryption/csfle-explicit_encryption.php b/source/examples/encryption/csfle-explicit_encryption.php index d36b4b32..eb5d584f 100644 --- a/source/examples/encryption/csfle-explicit_encryption.php +++ b/source/examples/encryption/csfle-explicit_encryption.php @@ -36,7 +36,7 @@ 'keyId' => $keyId, ]); -$collection = $client->selectCollection('test', 'coll'); +$collection = $client->getCollection('test', 'coll'); $collection->insertOne(['_id' => 1, 'encryptedField' => $encryptedValue]); /* Using the client configured without encryption, find the document and observe diff --git a/source/examples/encryption/csfle-explicit_encryption_automatic_decryption.php b/source/examples/encryption/csfle-explicit_encryption_automatic_decryption.php index 072b273a..c89e0af9 100644 --- a/source/examples/encryption/csfle-explicit_encryption_automatic_decryption.php +++ b/source/examples/encryption/csfle-explicit_encryption_automatic_decryption.php @@ -42,7 +42,7 @@ 'keyId' => $keyId, ]); -$collection = $client->selectCollection('test', 'coll'); +$collection = $client->getCollection('test', 'coll'); $collection->insertOne(['_id' => 1, 'encryptedField' => $encryptedValue]); /* Using the client configured with encryption (but not automatic encryption), diff --git a/source/examples/encryption/key_alt_name.php b/source/examples/encryption/key_alt_name.php index 03100aaf..ed72323d 100644 --- a/source/examples/encryption/key_alt_name.php +++ b/source/examples/encryption/key_alt_name.php @@ -18,8 +18,8 @@ /* Prepare the database for this script. Drop the key vault collection and * ensure it has a unique index for keyAltNames. This would typically be done * during application deployment. */ -$client->selectCollection('encryption', '__keyVault')->drop(); -$client->selectCollection('encryption', '__keyVault')->createIndex(['keyAltNames' => 1], [ +$client->getCollection('encryption', '__keyVault')->drop(); +$client->getCollection('encryption', '__keyVault')->createIndex(['keyAltNames' => 1], [ 'unique' => true, 'partialFilterExpression' => ['keyAltNames' => ['$exists' => true]], ]); diff --git a/source/examples/encryption/queryable_encryption-automatic.php b/source/examples/encryption/queryable_encryption-automatic.php index 024afe95..d148b118 100644 --- a/source/examples/encryption/queryable_encryption-automatic.php +++ b/source/examples/encryption/queryable_encryption-automatic.php @@ -59,8 +59,8 @@ * infer encryptedFields from the client configuration and manage internal * encryption collections automatically. Alternatively, the "encryptedFields" * option can also be passed explicitly. */ -$encryptedClient->selectDatabase('test')->createCollection('coll'); -$encryptedCollection = $encryptedClient->selectCollection('test', 'coll'); +$encryptedClient->getDatabase('test')->createCollection('coll'); +$encryptedCollection = $encryptedClient->getCollection('test', 'coll'); /* Using the encrypted client, insert a document and find it by querying on the * encrypted field. Fields will be automatically encrypted and decrypted. */ @@ -74,6 +74,6 @@ /* Using the client configured without encryption, find the same document and * observe that fields are not automatically decrypted. */ -$unencryptedCollection = $client->selectCollection('test', 'coll'); +$unencryptedCollection = $client->getCollection('test', 'coll'); print_r($unencryptedCollection->findOne(['_id' => 1])); diff --git a/source/examples/encryption/queryable_encryption-explicit.php b/source/examples/encryption/queryable_encryption-explicit.php index a07d88d1..66c55677 100644 --- a/source/examples/encryption/queryable_encryption-explicit.php +++ b/source/examples/encryption/queryable_encryption-explicit.php @@ -59,8 +59,8 @@ * option to ensure that internal encryption collections are also created. The * "encryptedFields" option should also be specified when dropping the * collection to ensure that internal encryption collections are dropped. */ -$encryptedClient->selectDatabase('test')->createCollection('coll', ['encryptedFields' => $encryptedFields]); -$encryptedCollection = $encryptedClient->selectCollection('test', 'coll'); +$encryptedClient->getDatabase('test')->createCollection('coll', ['encryptedFields' => $encryptedFields]); +$encryptedCollection = $encryptedClient->getCollection('test', 'coll'); // Insert a document with manually encrypted fields $indexedInsertPayload = $clientEncryption->encrypt('indexedValue', [ diff --git a/source/includes/databases-collections/databases-collections.php b/source/includes/databases-collections/databases-collections.php index 70215575..c571f5ee 100644 --- a/source/includes/databases-collections/databases-collections.php +++ b/source/includes/databases-collections/databases-collections.php @@ -10,7 +10,7 @@ // Accesses the "test_database" database // start-access-database -$db = $client->selectDatabase('test_database'); +$db = $client->getDatabase('test_database'); // end-access-database // Invokes the __get() method to access the "test_database" database @@ -20,7 +20,7 @@ // Accesses the "test_collection" collection // start-access-collection -$collection = $client->test_database->selectCollection('test_collection'); +$collection = $client->test_database->getCollection('test_collection'); // end-access-collection // Invokes the __get() method to access the "test_collection" collection @@ -51,7 +51,7 @@ $readConcern = new ReadConcern(ReadConcern::LOCAL); $writeConcern = new WriteConcern(WriteConcern::MAJORITY); -$db = $client->selectDatabase('test_database', [ +$db = $client->getDatabase('test_database', [ 'readPreference' => $readPreference, 'readConcern' => $readConcern, 'writeConcern' => $writeConcern, @@ -64,7 +64,7 @@ $readConcern = new ReadConcern(ReadConcern::AVAILABLE); $writeConcern = new WriteConcern(WriteConcern::MAJORITY); -$collection = $client->selectCollection('test_database', 'test_collection', [ +$collection = $client->getCollection('test_database', 'test_collection', [ 'readPreference' => $readPreference, 'readConcern' => $readConcern, 'writeConcern' => $writeConcern, @@ -85,7 +85,7 @@ ], ); -$db = $client->selectDatabase( +$db = $client->getDatabase( 'test_database', ['readPreference' => $readPreference], ); diff --git a/source/includes/read-write-pref.php b/source/includes/read-write-pref.php index 9c0c8ed9..9ce3c7c9 100644 --- a/source/includes/read-write-pref.php +++ b/source/includes/read-write-pref.php @@ -43,7 +43,7 @@ // Sets read and write settings for the "test_database" database // start-database-settings -$db = $client->selectDatabase('test_database', [ +$db = $client->getDatabase('test_database', [ 'readPreference' => new ReadPreference(ReadPreference::PRIMARY_PREFERRED), 'readConcern' => new ReadConcern(ReadConcern::AVAILABLE), 'writeConcern' => new WriteConcern(WriteConcern::MAJORITY), @@ -52,7 +52,7 @@ // Sets read and write settings for the "test_collection" collection // start-collection-settings -$collection = $client->selectCollection('test_database', 'test_collection', [ +$collection = $client->getCollection('test_database', 'test_collection', [ 'readPreference' => new ReadPreference(ReadPreference::SECONDARY_PREFERRED), 'readConcern' => new ReadConcern(ReadConcern::AVAILABLE), 'writeConcern' => new WriteConcern(0), @@ -73,7 +73,7 @@ ], ); -$db = $client->selectDatabase( +$db = $client->getDatabase( 'test_database', ['readPreference' => $readPreference], ); diff --git a/source/includes/usage-examples/sample-app.php b/source/includes/usage-examples/sample-app.php index f9d2cb83..6758e530 100644 --- a/source/includes/usage-examples/sample-app.php +++ b/source/includes/usage-examples/sample-app.php @@ -5,7 +5,7 @@ $uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset'); $client = new MongoDB\Client($uri); -$collection = $client->selectCollection('', ''); +$collection = $client->getCollection('', ''); // Start example code here diff --git a/source/includes/usage-examples/write-code-examples.php b/source/includes/usage-examples/write-code-examples.php index 8e508822..00e9d894 100644 --- a/source/includes/usage-examples/write-code-examples.php +++ b/source/includes/usage-examples/write-code-examples.php @@ -109,7 +109,7 @@ // Stores a file in a GridFS bucket and writes data to the file // start-gridfs-upload -$bucket = $client->selectDatabase('')->selectGridFSBucket(); +$bucket = $client->getDatabase('')->selectGridFSBucket(); $stream = $bucket->openUploadStream(''); fwrite($stream, ''); fclose($stream); diff --git a/source/includes/write/run-command.php b/source/includes/write/run-command.php index d074c337..ccde87fb 100644 --- a/source/includes/write/run-command.php +++ b/source/includes/write/run-command.php @@ -8,7 +8,7 @@ $client = new MongoDB\Client($uri); // start-hello -$database = $client->selectDatabase('myDB'); +$database = $client->getDatabase('myDB'); $cursor = $database->command(['hello' => 1]); // end-hello diff --git a/source/read-write-pref.txt b/source/read-write-pref.txt index fd324f9d..8b54f2da 100644 --- a/source/read-write-pref.txt +++ b/source/read-write-pref.txt @@ -64,9 +64,9 @@ following methods: settings - :ref:`MongoDB\Driver\Session::startTransaction() `: Configures transaction-level settings -- :ref:`MongoDB\Client::selectDatabase() `: Configures +- :ref:`MongoDB\Client::getDatabase() `: Configures database-level settings -- :ref:`MongoDB\Client::selectCollection() `: Configures +- :ref:`MongoDB\Client::getCollection() `: Configures collection-level settings .. _php-read-write-client: @@ -161,7 +161,7 @@ Database Configuration This example shows how to set the read preference, read concern, and write concern of a database called ``test_database`` by passing an options -array to the ``selectDatabase()`` method. The code configures the following settings: +array to the ``getDatabase()`` method. The code configures the following settings: - ``PRIMARY_PREFERRED`` read preference: Read operations retrieve data from the primary replica set member, or secondary members if the primary is unavailable @@ -184,7 +184,7 @@ Collection Configuration This example shows how to set the read preference, read concern, and write concern of a collection called ``test_collection`` by passing an options -array to the ``selectCollection()`` method. The code configures the following settings: +array to the ``getCollection()`` method. The code configures the following settings: - ``SECONDARY_PREFERRED`` read preference: Read operations retrieve data from secondary replica set members, or the primary members if no secondaries are available @@ -281,8 +281,8 @@ guide, see the following library API documentation: - :phpmethod:`MongoDB\Client::__construct()` - :phpmethod:`MongoDB\Client::startSession()` -- :phpmethod:`MongoDB\Client::selectDatabase()` -- :phpmethod:`MongoDB\Client::selectCollection()` +- :phpmethod:`MongoDB\Client::getDatabase()` +- :phpmethod:`MongoDB\Client::getCollection()` To learn more about the ``startTransaction()`` method, see :php:`MongoDB\Driver\Session::startTransaction() ` in the extension API documentation. diff --git a/source/reference/class/MongoDBClient.txt b/source/reference/class/MongoDBClient.txt index c7787203..27125c62 100644 --- a/source/reference/class/MongoDBClient.txt +++ b/source/reference/class/MongoDBClient.txt @@ -2,7 +2,6 @@ MongoDB\\Client Class ===================== - .. contents:: On this page :local: :backlinks: none @@ -32,6 +31,8 @@ Methods addSubscriber() createClientEncryption() dropDatabase() + getCollection() + getDatabase() getManager() getReadConcern() getReadPreference() @@ -50,6 +51,8 @@ Methods - :phpmethod:`MongoDB\Client::addSubscriber()` - :phpmethod:`MongoDB\Client::createClientEncryption()` - :phpmethod:`MongoDB\Client::dropDatabase()` +- :phpmethod:`MongoDB\Client::getCollection()` +- :phpmethod:`MongoDB\Client::getDatabase()` - :phpmethod:`MongoDB\Client::getManager()` - :phpmethod:`MongoDB\Client::getReadConcern()` - :phpmethod:`MongoDB\Client::getReadPreference()` diff --git a/source/reference/class/MongoDBCollection.txt b/source/reference/class/MongoDBCollection.txt index 746786b5..33e3e7e3 100644 --- a/source/reference/class/MongoDBCollection.txt +++ b/source/reference/class/MongoDBCollection.txt @@ -21,7 +21,7 @@ Definition :php:`MongoDB\Driver\Manager ` class or select a collection from the library's :phpclass:`MongoDB\Client` or :phpclass:`MongoDB\Database` classes. A collection may also be cloned from - an existing :phpclass:`MongoDB\Collection` object via the + an existing :phpclass:`MongoDB\Collection` object by using the :phpmethod:`withOptions() ` method. :phpclass:`MongoDB\Collection` supports the :php:`readConcern diff --git a/source/reference/class/MongoDBDatabase.txt b/source/reference/class/MongoDBDatabase.txt index b392a6b7..37208d4e 100644 --- a/source/reference/class/MongoDBDatabase.txt +++ b/source/reference/class/MongoDBDatabase.txt @@ -21,7 +21,7 @@ Definition :php:`MongoDB\Driver\Manager ` class or select a database from the library's :phpclass:`MongoDB\Client` class. A database may also be cloned from an existing :phpclass:`MongoDB\Database` - object via the :phpmethod:`withOptions() ` + object by using the :phpmethod:`withOptions() ` method. :phpclass:`MongoDB\Database` supports the :php:`readConcern @@ -50,6 +50,7 @@ Methods createEncryptedCollection() drop() dropCollection() + getCollection() getDatabaseName() getManager() getReadConcern() @@ -73,6 +74,7 @@ Methods - :phpmethod:`MongoDB\Database::createEncryptedCollection()` - :phpmethod:`MongoDB\Database::drop()` - :phpmethod:`MongoDB\Database::dropCollection()` +- :phpmethod:`MongoDB\Database::getCollection()` - :phpmethod:`MongoDB\Database::getDatabaseName()` - :phpmethod:`MongoDB\Database::getManager()` - :phpmethod:`MongoDB\Database::getReadConcern()` diff --git a/source/reference/method/MongoDBClient-getCollection.txt b/source/reference/method/MongoDBClient-getCollection.txt new file mode 100644 index 00000000..7484d96d --- /dev/null +++ b/source/reference/method/MongoDBClient-getCollection.txt @@ -0,0 +1,127 @@ +================================ +MongoDB\\Client::getCollection() +================================ + + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. phpmethod:: MongoDB\Client::getCollection() + + Gets access to a collection on the server. This method is an alias for + :phpmethod:`MongoDB\Client::selectCollection()` and will replace it in + a future release. + + .. code-block:: php + + function getCollection( + string $databaseName, + string $collectionName, + array $options = [] + ): MongoDB\Collection + +Parameters +---------- + +``$databaseName`` : string + The name of the database containing the collection to access. + +``$collectionName`` : string + The name of the collection to access. + +``$options`` : array + An array specifying the desired options. + + .. list-table:: + :header-rows: 1 + :widths: 20 20 80 + + * - Name + - Type + - Description + + * - codec + - MongoDB\\Codec\\DocumentCodec + - The default :doc:`codec ` to use for collection + operations. + + .. versionadded:: 1.17 + + * - readConcern + - :php:`MongoDB\Driver\ReadConcern ` + - The default read concern to use for collection operations. Defaults to + the client's read concern. + + * - readPreference + - :php:`MongoDB\Driver\ReadPreference ` + - The default read preference to use for collection operations. Defaults + to the client's read preference. + + * - typeMap + - array + - The default type map to use for collection operations. Defaults to the + client's type map. + + * - writeConcern + - :php:`MongoDB\Driver\WriteConcern ` + - The default write concern to use for collection operations. Defaults to + the client's write concern. + +Return Values +------------- + +A :phpclass:`MongoDB\Collection` object. + +Errors/Exceptions +----------------- + +.. include:: /includes/extracts/error-invalidargumentexception.rst + +Behavior +-------- + +The selected collection inherits options such as read preference and type +mapping from the :phpclass:`Client ` object. Options may be +overridden by using the ``$options`` parameter. + +Example +------- + +The following example gets access to the ``users`` collection in the ``test`` database: + +.. code-block:: php + + getCollection('test', 'users'); + +The following example gets access to the ``users`` collection in the ``test`` database +with a custom read preference: + +.. code-block:: php + + getCollection( + 'test', + 'users', + [ + 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), + ] + ); + +See Also +-------- + +- :phpmethod:`MongoDB\Collection::__construct()` +- :phpmethod:`MongoDB\Database::getCollection()` diff --git a/source/reference/method/MongoDBClient-getDatabase.txt b/source/reference/method/MongoDBClient-getDatabase.txt new file mode 100644 index 00000000..48860b74 --- /dev/null +++ b/source/reference/method/MongoDBClient-getDatabase.txt @@ -0,0 +1,114 @@ +============================== +MongoDB\\Client::getDatabase() +============================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. phpmethod:: MongoDB\Client::getDatabase() + + Gets access to a database on the server. This method is an alias for + :phpmethod:`MongoDB\Client::selectDatabase()` and will replace it in + a future release. + + .. code-block:: php + + function getDatabase( + string $databaseName, + array $options = [] + ): MongoDB\Database + +Parameters +---------- + +``$databaseName`` : string + The name of the database to access. + +``$options`` : array + An array specifying the desired options. + + .. list-table:: + :header-rows: 1 + :widths: 20 20 80 + + * - Name + - Type + - Description + + * - readConcern + - :php:`MongoDB\Driver\ReadConcern ` + - The default read concern to use for database operations. Defaults to + the client's read concern. + + * - readPreference + - :php:`MongoDB\Driver\ReadPreference ` + - The default read preference to use for database operations. Defaults to + the client's read preference. + + * - typeMap + - array + - The default type map to use for database operations. Defaults to the + client's type map. + + * - writeConcern + - :php:`MongoDB\Driver\WriteConcern ` + - The default write concern to use for database operations. Defaults to + the client's write concern. + +Return Values +------------- + +A :phpclass:`MongoDB\Database` object. + +Errors/Exceptions +----------------- + +.. include:: /includes/extracts/error-invalidargumentexception.rst + +Behavior +-------- + +The selected database inherits options such as read preference and type mapping +from the :phpclass:`Client ` object. Options may be overridden +by using the ``$options`` parameter. + +Example +------- + +The following example gets access to the ``test`` database: + +.. code-block:: php + + getDatabase('test'); + +The following examples gets access to the ``test`` database with a custom read +preference: + +.. code-block:: php + + getDatabase( + 'test', + [ + 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), + ] + ); + +See Also +-------- + +- :phpmethod:`MongoDB\Client::__get()` +- :phpmethod:`MongoDB\Database::__construct()` diff --git a/source/reference/method/MongoDBClient-selectCollection.txt b/source/reference/method/MongoDBClient-selectCollection.txt index 3b181d08..0b6ff683 100644 --- a/source/reference/method/MongoDBClient-selectCollection.txt +++ b/source/reference/method/MongoDBClient-selectCollection.txt @@ -14,7 +14,9 @@ Definition .. phpmethod:: MongoDB\Client::selectCollection() - Selects a collection on the server. + Selects a collection on the server. This method is aliased by + :phpmethod:`MongoDB\Client::getCollection()` and will be replaced by + it in a future release. .. code-block:: php @@ -86,7 +88,7 @@ Behavior The selected collection inherits options such as read preference and type mapping from the :phpclass:`Client ` object. Options may be -overridden via the ``$options`` parameter. +overridden by using the ``$options`` parameter. Example ------- diff --git a/source/reference/method/MongoDBClient-selectDatabase.txt b/source/reference/method/MongoDBClient-selectDatabase.txt index 8c786b61..8b3c3fa2 100644 --- a/source/reference/method/MongoDBClient-selectDatabase.txt +++ b/source/reference/method/MongoDBClient-selectDatabase.txt @@ -2,7 +2,6 @@ MongoDB\\Client::selectDatabase() ================================= - .. contents:: On this page :local: :backlinks: none @@ -14,14 +13,16 @@ Definition .. phpmethod:: MongoDB\Client::selectDatabase() - Selects a database on the server. + Selects a database on the server. This method is aliased by + :phpmethod:`MongoDB\Client::getDatabase()` and will be replaced by + it in a future release. .. code-block:: php - function selectDatabase( - string $databaseName, - array $options = [] - ): MongoDB\Database + function selectDatabase( + string $databaseName, + array $options = [] + ): MongoDB\Database Parameters ---------- @@ -33,32 +34,32 @@ Parameters An array specifying the desired options. .. list-table:: - :header-rows: 1 - :widths: 20 20 80 + :header-rows: 1 + :widths: 20 20 80 - * - Name - - Type - - Description + * - Name + - Type + - Description - * - readConcern - - :php:`MongoDB\Driver\ReadConcern ` - - The default read concern to use for database operations. Defaults to - the client's read concern. + * - readConcern + - :php:`MongoDB\Driver\ReadConcern ` + - The default read concern to use for database operations. Defaults to + the client's read concern. - * - readPreference - - :php:`MongoDB\Driver\ReadPreference ` - - The default read preference to use for database operations. Defaults to - the client's read preference. + * - readPreference + - :php:`MongoDB\Driver\ReadPreference ` + - The default read preference to use for database operations. Defaults to + the client's read preference. - * - typeMap - - array - - The default type map to use for database operations. Defaults to the - client's type map. + * - typeMap + - array + - The default type map to use for database operations. Defaults to the + client's type map. - * - writeConcern - - :php:`MongoDB\Driver\WriteConcern ` - - The default write concern to use for database operations. Defaults to - the client's write concern. + * - writeConcern + - :php:`MongoDB\Driver\WriteConcern ` + - The default write concern to use for database operations. Defaults to + the client's write concern. Return Values ------------- @@ -75,7 +76,7 @@ Behavior The selected database inherits options such as read preference and type mapping from the :phpclass:`Client ` object. Options may be overridden -via the ``$options`` parameter. +by using the ``$options`` parameter. Example ------- @@ -100,10 +101,10 @@ preference: $client = new MongoDB\Client; $db = $client->selectDatabase( - 'test', - [ - 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), - ] + 'test', + [ + 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), + ] ); See Also diff --git a/source/reference/method/MongoDBCollection-createIndex.txt b/source/reference/method/MongoDBCollection-createIndex.txt index c9408a4f..aabb5679 100644 --- a/source/reference/method/MongoDBCollection-createIndex.txt +++ b/source/reference/method/MongoDBCollection-createIndex.txt @@ -153,7 +153,7 @@ the ``test`` database. selectCollection('test', 'restaurants'); + $collection = (new MongoDB\Client)->getCollection('test', 'restaurants'); $indexName = $collection->createIndex(['borough' => 1, 'cuisine' => 1]); @@ -177,7 +177,7 @@ exists. selectCollection('test', 'restaurants'); + $collection = (new MongoDB\Client)->getCollection('test', 'restaurants'); $indexName = $collection->createIndex( ['borough' => 1], diff --git a/source/reference/method/MongoDBCollection-createIndexes.txt b/source/reference/method/MongoDBCollection-createIndexes.txt index 34078b18..b1f4c7c7 100644 --- a/source/reference/method/MongoDBCollection-createIndexes.txt +++ b/source/reference/method/MongoDBCollection-createIndexes.txt @@ -142,7 +142,7 @@ custom name. selectCollection('test', 'restaurants'); + $collection = (new MongoDB\Client)->getCollection('test', 'restaurants'); $indexNames = $collection->createIndexes([ [ 'key' => [ 'borough' => 1, 'cuisine' => 1] ], diff --git a/source/reference/method/MongoDBCollection-createSearchIndex.txt b/source/reference/method/MongoDBCollection-createSearchIndex.txt index 0cd4de2e..840281ec 100644 --- a/source/reference/method/MongoDBCollection-createSearchIndex.txt +++ b/source/reference/method/MongoDBCollection-createSearchIndex.txt @@ -88,7 +88,7 @@ to index all document fields containing selectCollection('test', 'articles'); + $collection = (new MongoDB\Client)->getCollection('test', 'articles'); $indexName = $collection->createSearchIndex( ['mappings' => ['dynamic' => true]], diff --git a/source/reference/method/MongoDBCollection-createSearchIndexes.txt b/source/reference/method/MongoDBCollection-createSearchIndexes.txt index bee786fa..f9124f57 100644 --- a/source/reference/method/MongoDBCollection-createSearchIndexes.txt +++ b/source/reference/method/MongoDBCollection-createSearchIndexes.txt @@ -88,7 +88,7 @@ to index all document fields containing selectCollection('test', 'articles'); + $collection = (new MongoDB\Client)->getCollection('test', 'articles'); $indexNames = $collection->createSearchIndexes( [ diff --git a/source/reference/method/MongoDBCollection-getReadConcern.txt b/source/reference/method/MongoDBCollection-getReadConcern.txt index 88d71c77..fd51e3db 100644 --- a/source/reference/method/MongoDBCollection-getReadConcern.txt +++ b/source/reference/method/MongoDBCollection-getReadConcern.txt @@ -34,7 +34,7 @@ Example selectCollection('test', 'users', [ + $collection = (new MongoDB\Client)->getCollection('test', 'users', [ 'readConcern' => new MongoDB\Driver\ReadConcern('majority'), ]); diff --git a/source/reference/method/MongoDBCollection-getReadPreference.txt b/source/reference/method/MongoDBCollection-getReadPreference.txt index 42f1e5c6..8bbb22e7 100644 --- a/source/reference/method/MongoDBCollection-getReadPreference.txt +++ b/source/reference/method/MongoDBCollection-getReadPreference.txt @@ -35,7 +35,7 @@ Example selectCollection('test', 'users', [ + $collection = (new MongoDB\Client)->getCollection('test', 'users', [ 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), ]); diff --git a/source/reference/method/MongoDBCollection-getTypeMap.txt b/source/reference/method/MongoDBCollection-getTypeMap.txt index 05517e1a..02ac773d 100644 --- a/source/reference/method/MongoDBCollection-getTypeMap.txt +++ b/source/reference/method/MongoDBCollection-getTypeMap.txt @@ -34,7 +34,7 @@ Example selectCollection('test', 'users', [ + $collection = (new MongoDB\Client)->getCollection('test', 'users', [ 'typeMap' => [ 'root' => 'array', 'document' => 'array', diff --git a/source/reference/method/MongoDBCollection-getWriteConcern.txt b/source/reference/method/MongoDBCollection-getWriteConcern.txt index ea1bd035..aaf867eb 100644 --- a/source/reference/method/MongoDBCollection-getWriteConcern.txt +++ b/source/reference/method/MongoDBCollection-getWriteConcern.txt @@ -35,7 +35,7 @@ Example selectCollection('test', 'users', [ + $collection = (new MongoDB\Client)->getCollection('test', 'users', [ 'writeConcern' => new MongoDB\Driver\WriteConcern(1, 0, true), ]); diff --git a/source/reference/method/MongoDBCollection-withOptions.txt b/source/reference/method/MongoDBCollection-withOptions.txt index 9447bdbd..1893b9db 100644 --- a/source/reference/method/MongoDBCollection-withOptions.txt +++ b/source/reference/method/MongoDBCollection-withOptions.txt @@ -83,7 +83,7 @@ preference: selectCollection('test', 'restaurants'); + $collection = (new MongoDB\Client)->getCollection('test', 'restaurants'); $newCollection = $sourceCollection->withOptions([ 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), diff --git a/source/reference/method/MongoDBCollection__construct.txt b/source/reference/method/MongoDBCollection__construct.txt index 1ff202dc..0cdc4219 100644 --- a/source/reference/method/MongoDBCollection__construct.txt +++ b/source/reference/method/MongoDBCollection__construct.txt @@ -105,6 +105,6 @@ See Also -------- - :phpmethod:`MongoDB\Collection::withOptions()` -- :phpmethod:`MongoDB\Client::selectCollection()` -- :phpmethod:`MongoDB\Database::selectCollection()` +- :phpmethod:`MongoDB\Client::getCollection()` +- :phpmethod:`MongoDB\Database::getCollection()` - :phpmethod:`MongoDB\Database::__get()` diff --git a/source/reference/method/MongoDBDatabase-getCollection.txt b/source/reference/method/MongoDBDatabase-getCollection.txt new file mode 100644 index 00000000..6199c81c --- /dev/null +++ b/source/reference/method/MongoDBDatabase-getCollection.txt @@ -0,0 +1,123 @@ +===================================== +MongoDB\\Database::getCollection() +===================================== + + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. phpmethod:: MongoDB\Database::getCollection() + + Gets access to a collection within the database. This method is an alias for + :phpmethod:`MongoDB\Database::selectCollection()` and will replace it in + a future release. + + .. code-block:: php + + function getCollection( + string $collectionName, + array $options = [] + ): MongoDB\Collection + +Parameters +---------- + +``$collectionName`` : string + The name of the collection to access. + +``$options`` : array + An array specifying the desired options. + + .. list-table:: + :header-rows: 1 + :widths: 20 20 80 + + * - Name + - Type + - Description + + * - codec + - MongoDB\\Codec\\DocumentCodec + - The default :doc:`codec ` to use for collection + operations. + + .. versionadded:: 1.17 + + * - readConcern + - :php:`MongoDB\Driver\ReadConcern ` + - The default read concern to use for collection operations. Defaults to + the database's read concern. + + * - readPreference + - :php:`MongoDB\Driver\ReadPreference ` + - The default read preference to use for collection operations. Defaults + to the database's read preference. + + * - typeMap + - array + - The default type map to use for collection operations. Defaults to the + database's type map. + + * - writeConcern + - :php:`MongoDB\Driver\WriteConcern ` + - The default write concern to use for collection operations. Defaults to + the database's write concern. + +Return Values +------------- + +A :phpclass:`MongoDB\Collection` object. + +Errors/Exceptions +----------------- + +.. include:: /includes/extracts/error-invalidargumentexception.rst + +Behavior +-------- + +The selected collection inherits options such as read preference and type +mapping from the :phpclass:`Database ` object. Options may be +overridden by using the ``$options`` parameter. + +Example +------- + +The following example gets access to the ``users`` collection in the ``test`` database: + +.. code-block:: php + + test; + + $collection = $db->getCollection('users'); + +The following example gets access to the ``users`` collection in the ``test`` +database with a custom read preference: + +.. code-block:: php + + test; + + $users = $db->getCollection( + 'users', + [ + 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), + ] + ); + +See Also +-------- + +- :phpmethod:`MongoDB\Database::__get()` +- :phpmethod:`MongoDB\Client::getCollection()` +- :phpmethod:`MongoDB\Collection::__construct()` diff --git a/source/reference/method/MongoDBDatabase-getReadConcern.txt b/source/reference/method/MongoDBDatabase-getReadConcern.txt index d3500ae7..9f8338f0 100644 --- a/source/reference/method/MongoDBDatabase-getReadConcern.txt +++ b/source/reference/method/MongoDBDatabase-getReadConcern.txt @@ -34,7 +34,7 @@ Example selectDatabase('test', [ + $database = (new MongoDB\Client)->getDatabase('test', [ 'readConcern' => new MongoDB\Driver\ReadConcern('majority'), ]); diff --git a/source/reference/method/MongoDBDatabase-getReadPreference.txt b/source/reference/method/MongoDBDatabase-getReadPreference.txt index 92b6e426..64298b8c 100644 --- a/source/reference/method/MongoDBDatabase-getReadPreference.txt +++ b/source/reference/method/MongoDBDatabase-getReadPreference.txt @@ -35,7 +35,7 @@ Example selectDatabase('test', [ + $database = (new MongoDB\Client)->getDatabase('test', [ 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), ]); diff --git a/source/reference/method/MongoDBDatabase-getTypeMap.txt b/source/reference/method/MongoDBDatabase-getTypeMap.txt index 2e73768a..b1be27d6 100644 --- a/source/reference/method/MongoDBDatabase-getTypeMap.txt +++ b/source/reference/method/MongoDBDatabase-getTypeMap.txt @@ -34,7 +34,7 @@ Example selectDatabase('test', [ + $database = (new MongoDB\Client)->getDatabase('test', [ 'typeMap' => [ 'root' => 'array', 'document' => 'array', diff --git a/source/reference/method/MongoDBDatabase-getWriteConcern.txt b/source/reference/method/MongoDBDatabase-getWriteConcern.txt index 4dc2ae0e..07eb4866 100644 --- a/source/reference/method/MongoDBDatabase-getWriteConcern.txt +++ b/source/reference/method/MongoDBDatabase-getWriteConcern.txt @@ -35,7 +35,7 @@ Example selectDatabase('test', [ + $database = (new MongoDB\Client)->getDatabase('test', [ 'writeConcern' => new MongoDB\Driver\WriteConcern(1, 0, true), ]); diff --git a/source/reference/method/MongoDBDatabase-selectCollection.txt b/source/reference/method/MongoDBDatabase-selectCollection.txt index fd0f97e1..c6eb1549 100644 --- a/source/reference/method/MongoDBDatabase-selectCollection.txt +++ b/source/reference/method/MongoDBDatabase-selectCollection.txt @@ -14,7 +14,9 @@ Definition .. phpmethod:: MongoDB\Database::selectCollection() - Selects a collection within the database. + Selects a collection within the database. This method is aliased by + :phpmethod:`MongoDB\Database::getCollection()` and will be replaced by + it in a future release. .. code-block:: php @@ -82,7 +84,7 @@ Behavior The selected collection inherits options such as read preference and type mapping from the :phpclass:`Database ` object. Options may be -overridden via the ``$options`` parameter. +overridden by using the ``$options`` parameter. Example ------- diff --git a/source/reference/method/MongoDBDatabase__construct.txt b/source/reference/method/MongoDBDatabase__construct.txt index fd37bc8c..c952b320 100644 --- a/source/reference/method/MongoDBDatabase__construct.txt +++ b/source/reference/method/MongoDBDatabase__construct.txt @@ -92,5 +92,5 @@ See Also -------- - :phpmethod:`MongoDB\Database::withOptions()` -- :phpmethod:`MongoDB\Client::selectDatabase()` +- :phpmethod:`MongoDB\Client::getDatabase()` - :phpmethod:`MongoDB\Client::__get()` diff --git a/source/reference/method/MongoDBDatabase__get.txt b/source/reference/method/MongoDBDatabase__get.txt index 9237155a..e3be6e71 100644 --- a/source/reference/method/MongoDBDatabase__get.txt +++ b/source/reference/method/MongoDBDatabase__get.txt @@ -36,7 +36,7 @@ Behavior The selected collection inherits options such as read preference and type mapping from the :phpclass:`Database ` object. If you wish to -override any options, use the :phpmethod:`MongoDB\Database::selectCollection()` +override any options, use the :phpmethod:`MongoDB\Database::getCollection()` method. .. note:: @@ -44,7 +44,7 @@ method. To select collections whose names contain special characters, such as ``.``, use complex syntax, as in ``$database->{'that.database'}``. - Alternatively, :phpmethod:`MongoDB\Database::selectCollection()` supports + Alternatively, :phpmethod:`MongoDB\Database::getCollection()` supports selecting collections whose names contain special characters. Examples @@ -65,6 +65,6 @@ collections from the ``test`` database: See Also -------- -- :phpmethod:`MongoDB\Database::selectCollection()` -- :phpmethod:`MongoDB\Client::selectCollection()` +- :phpmethod:`MongoDB\Database::getCollection()` +- :phpmethod:`MongoDB\Client::getCollection()` - :php:`Property Overloading ` in the PHP Manual diff --git a/source/reference/method/MongoDBGridFSBucket-getReadConcern.txt b/source/reference/method/MongoDBGridFSBucket-getReadConcern.txt index a8345de0..129de63e 100644 --- a/source/reference/method/MongoDBGridFSBucket-getReadConcern.txt +++ b/source/reference/method/MongoDBGridFSBucket-getReadConcern.txt @@ -34,7 +34,7 @@ Example selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket([ 'readConcern' => new MongoDB\Driver\ReadConcern('majority'), ]); diff --git a/source/reference/method/MongoDBGridFSBucket-getReadPreference.txt b/source/reference/method/MongoDBGridFSBucket-getReadPreference.txt index a6f0fbb3..95cda947 100644 --- a/source/reference/method/MongoDBGridFSBucket-getReadPreference.txt +++ b/source/reference/method/MongoDBGridFSBucket-getReadPreference.txt @@ -35,7 +35,7 @@ Example selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket([ 'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'), ]); diff --git a/source/reference/method/MongoDBGridFSBucket-getTypeMap.txt b/source/reference/method/MongoDBGridFSBucket-getTypeMap.txt index 960c3494..ff70218d 100644 --- a/source/reference/method/MongoDBGridFSBucket-getTypeMap.txt +++ b/source/reference/method/MongoDBGridFSBucket-getTypeMap.txt @@ -34,7 +34,7 @@ Example selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket([ 'typeMap' => [ 'root' => 'array', diff --git a/source/reference/method/MongoDBGridFSBucket-getWriteConcern.txt b/source/reference/method/MongoDBGridFSBucket-getWriteConcern.txt index 0c73a518..541e1461 100644 --- a/source/reference/method/MongoDBGridFSBucket-getWriteConcern.txt +++ b/source/reference/method/MongoDBGridFSBucket-getWriteConcern.txt @@ -35,7 +35,7 @@ Example selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket([ 'writeConcern' => new MongoDB\Driver\WriteConcern(1, 0, true), ]); diff --git a/source/reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias.txt b/source/reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias.txt index 58210a57..2847668b 100644 --- a/source/reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias.txt +++ b/source/reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias.txt @@ -76,7 +76,7 @@ Each call to these functions makes a request to the server. selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket(); $bucket->registerGlobalStreamWrapperAlias('mybucket'); @@ -109,7 +109,7 @@ read. If omitted, the most recent revision is read. selectDatabase('test'); + $database = (new MongoDB\Client)->getDatabase('test'); $bucket = $database->selectGridFSBucket(); $bucket->registerGlobalStreamWrapperAlias('mybucket'); diff --git a/source/reference/method/MongoDBModelIndexInfo-is2dSphere.txt b/source/reference/method/MongoDBModelIndexInfo-is2dSphere.txt index d7ca0437..a64d85fc 100644 --- a/source/reference/method/MongoDBModelIndexInfo-is2dSphere.txt +++ b/source/reference/method/MongoDBModelIndexInfo-is2dSphere.txt @@ -35,7 +35,7 @@ Examples selectCollection('test', 'places'); + $collection = (new MongoDB\Client)->getCollection('test', 'places'); $collection->createIndex(['pos' => '2dsphere']); diff --git a/source/reference/method/MongoDBModelIndexInfo-isText.txt b/source/reference/method/MongoDBModelIndexInfo-isText.txt index 8e3c6ad1..4150b040 100644 --- a/source/reference/method/MongoDBModelIndexInfo-isText.txt +++ b/source/reference/method/MongoDBModelIndexInfo-isText.txt @@ -34,7 +34,7 @@ Examples selectCollection('test', 'restaurants'); + $collection = (new MongoDB\Client)->getCollection('test', 'restaurants'); $collection->createIndex(['name' => 'text']); diff --git a/source/whats-new.txt b/source/whats-new.txt index 9a039fe4..3b60fb17 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -21,13 +21,10 @@ Learn about new features, improvements, and fixes introduced in the following versions of the {+php-library+}: * :ref:`Version 2.0 ` - +* :ref:`Version 1.21 ` * :ref:`Version 1.20 ` - * :ref:`Version 1.19 ` - * :ref:`Version 1.18 ` - * :ref:`Version 1.17 ` .. _php-lib-version-2.0: @@ -56,12 +53,23 @@ What's New in 2.0 The {+library-short+} v2.0 release includes the following API changes and removals: +- Adds the following methods: + + - :phpmethod:`MongoDB\Client::getDatabase()`: alias for :phpmethod:`MongoDB\Client::selectDatabase()` + - :phpmethod:`MongoDB\Client::getCollection()`: alias for :phpmethod:`MongoDB\Client::selectCollection()` + - :phpmethod:`MongoDB\Database::getCollection()`: alias for :phpmethod:`MongoDB\Database::selectCollection()` + + The ``Client::selectCollection()``, ``Client::selectDatabase()``, and + ``Database::selectCollection()`` methods will be deprecated and + replaced by these new methods in a future driver release, so consider + changing the usages in your application. + - Removes deprecated fields in GridFS types. - - The library does not calculate the ``md5`` field when a file is - uploaded to GridFS. If your application requires a file digest, you - must implement this process outside GridFS and store the values in - metadata. + - The library does not calculate the ``md5`` field when a file is + uploaded to GridFS. If your application requires a file digest, you + must implement this process outside GridFS and store the values in + metadata. - The fields ``contentType`` and ``aliases`` are no longer stored in the ``files`` GridFS collection. If your application requires this @@ -108,6 +116,25 @@ and removals: general traversable ``Iterator`` instance that provides the corresponding results. +.. _php-lib-version-1.21: + +What's New in 1.21 +------------------ + +The {+library-short+} v1.21 release includes the following features, +improvements, and fixes: + +- Adds the following methods: + + - :phpmethod:`MongoDB\Client::getDatabase()`: alias for :phpmethod:`MongoDB\Client::selectDatabase()` + - :phpmethod:`MongoDB\Database::getCollection()`: alias for :phpmethod:`MongoDB\Database::selectCollection()` + - :phpmethod:`MongoDB\Database::getCollection()`: alias for :phpmethod:`MongoDB\Database::selectCollection()` + + The ``Client::selectCollection()``, ``Client::selectDatabase()``, and + ``Database::selectCollection()`` methods will be deprecated and + replaced by these new methods in a future driver release, so consider + changing the usages in your application. + .. _php-lib-version-1.20: What's New in 1.20