Skip to content

PHPLIB-1055: Various small documentation fixes #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBClient-selectCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ with a custom read preference:
'test',
'users',
[
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]
);

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBClient-selectDatabase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ preference:
$db = $client->selectDatabase(
'test',
[
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]
);

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBCollection-getReadConcern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example
<?php

$collection = (new MongoDB\Client)->selectCollection('test', 'users', [
'readConcern' => new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
'readConcern' => new MongoDB\Driver\ReadConcern('majority'),
]);

var_dump($collection->getReadConcern());
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBCollection-updateMany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The following example updates all of the documents with the ``borough`` of

$updateResult = $collection->updateMany(
[ 'borough' => 'Queens' ],
[ '$set' => [ 'active' => 'True' ]]
[ '$set' => [ 'active' => true ]]
);

printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBCollection-withOptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ preference:
$collection = (new MongoDB\Client)->selectCollection('test', 'restaurants');

$newCollection = $sourceCollection->withOptions([
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]);

See Also
Expand Down
23 changes: 14 additions & 9 deletions docs/reference/method/MongoDBDatabase-command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Definition

.. phpmethod:: MongoDB\\Database::command()

Execute a :manual:`command </reference/command>` on the database.
Execute a :manual:`command </reference/command>` on the database. This is
generally used to execute commands that do not have a corresponding helper
method within the library.

.. code-block:: php

Expand Down Expand Up @@ -43,9 +45,10 @@ Errors/Exceptions
Example
-------

The following example executes a :manual:`ping
</reference/command/ping>` command, which returns a cursor with a single
result document:
Most database commands return a single result document, which can be obtained by
converting the returned cursor to an array and accessing its first element. The
following example executes a :manual:`ping </reference/command/ping>` command
and prints its result document:

.. code-block:: php

Expand All @@ -55,7 +58,7 @@ result document:

$cursor = $database->command(['ping' => 1]);

var_dump($c->toArray()[0]);
var_dump($cursor->toArray()[0]);

The output would resemble:

Expand All @@ -69,9 +72,11 @@ The output would resemble:
}
}

The following example executes a :manual:`listCollections
</reference/command/listCollections>` command, which returns a cursor with
multiple result documents:
Some database commands return a cursor with multiple results. The following
example executes :manual:`listCollections </reference/command/listCollections>`,
which returns a cursor containing a result document for each collection in the
``test`` database. Note that this example is illustrative; applications would
generally use :phpmethod:`MongoDB\\Database::listCollections()` in practice.

.. code-block:: php

Expand All @@ -81,7 +86,7 @@ multiple result documents:

$cursor = $database->command(['listCollections' => 1]);

var_dump($c->toArray());
var_dump($cursor->toArray());

The output would resemble:

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBDatabase-getReadConcern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example
<?php

$database = (new MongoDB\Client)->selectDatabase('test', [
'readConcern' => new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
'readConcern' => new MongoDB\Driver\ReadConcern('majority'),
]);

var_dump($database->getReadConcern());
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBDatabase-selectCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ database with a custom read preference:
$users = $db->selectCollection(
'users',
[
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ database with a custom read preference:

$imagesBucket = $db->selectGridFSBucket([
'bucketName' => 'images',
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]);

See Also
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBDatabase-withOptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ preference:
$db = (new MongoDB\Client)->test;

$newDb = $db->withOptions([
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]);

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Example

$database = (new MongoDB\Client)->selectDatabase('test');
$bucket = $database->selectGridFSBucket([
'readConcern' => new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
'readConcern' => new MongoDB\Driver\ReadConcern('majority'),
]);

var_dump($bucket->getReadConcern());
Expand Down
8 changes: 6 additions & 2 deletions docs/reference/method/MongoDBModelIndexInfo-isGeoHaystack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ Definition

.. phpmethod:: MongoDB\\Model\\IndexInfo::isGeoHaystack()

Return whether the index is a :manual:`geoHaystack
</core/geohaystack>` index.
Return whether the index is a :manual:`geoHaystack </core/geohaystack>`
index.

.. code-block:: php

function isGeoHaystack(): boolean

.. note::

MongoDB 5.0 and later no longer supports geoHaystack indexes.

Return Values
-------------

Expand Down
Loading