Commit 818e4506 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #281

parents 63a5d216 3828fbc6
......@@ -60,18 +60,10 @@ repository:
repository.
* Install [giza](https://pypi.python.org/pypi/giza/), as noted in the tools
README.
* Comment out the following `assets` entry in `config/build_conf.yaml`:
```
- branch: master
path: build/php-library # this is where we'll put the source docs (from the driver repo)
repository: https://github.com/mongodb/mongo-php-library.git
```
* Create a symlink so that `build/php-library` points to your working copy of
the [mongodb/mongo-php-library](https://github.com/mongodb/mongo-php-library)
repository.
* Build the documentation with `giza make html`. You can suppress informational
log messages via the `--level warning` option.
* Sync your working copy of the documentation to the `source/` directory with
`rsync -a --delete /path/to/mongo-php-library/docs/ source/`.
* Build the documentation with `giza make publish`. You can suppress
informational log messages with the `--level warning` option.
* Generated documentation may be found in the `build/master/html` directory.
## Releasing
......
......@@ -17,4 +17,99 @@ description: |
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: allow_invalid_hostname
type: boolean
description: |
Disables hostname validation if ``true``. Defaults to ``false``.
Allowing invalid hostnames may expose the driver to a `man-in-the-middle
attack <https://en.wikipedia.org/wiki/Man-in-the-middle_attack>`_.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: ca_dir
type: string
description: |
Path to a correctly hashed certificate directory. The system certificate store
will be used by default.
Falls back to the deprecated ``capath`` SSL context option if not specified.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: ca_file
type: string
description: |
Path to a certificate authority file. The system certificate store will be
used by default.
Falls back to the deprecated ``cafile`` SSL context option if not specified.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: crl_file
type: string
description: |
Path to a certificate revocation list file.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: pem_file
type: string
description: |
Path to a PEM encoded certificate to use for client authentication.
Falls back to the deprecated ``local_cert`` SSL context option if not
specified.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: pem_pwd
type: string
description: |
Passphrase for the PEM encoded certificate (if applicable).
Falls back to the deprecated ``passphrase`` SSL context option if not
specified.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: weak_cert_validation
type: boolean
description: |
Disables certificate validation ``true``. Defaults to ``false``.
Falls back to the deprecated ``allow_self_signed`` SSL context option if not
specified.
interface: phpmethod
operation: ~
optional: true
---
arg_name: option
name: context
type: resource
description: |
:php:`SSL context options <manual/en/context.ssl.php>` to be used as fallbacks
for other driver options (as specified). Note that the driver does not consult
the default stream context.
This option is supported for backwards compatibility, but should be considered
deprecated.
interface: phpmethod
operation: ~
optional: true
...
......@@ -3,10 +3,18 @@ name: $uri
type: string
description: |
The URI of the standalone, replica set, or sharded cluster to which to
connect. Refer to the :manual:`MongoDB connection string reference
</reference/connection-string>` for formatting.
connect. Refer to :manual:`Connection String URI Format
</reference/connection-string>` in the MongoDB manual for more information.
Defaults to ``"mongodb://127.0.0.1:27017"`` if unspecified.
Any special characters in the URI components need to be encoded according to
`RFC 3986 <http://www.faqs.org/rfcs/rfc3986.html>`_. This is particularly
relevant to the username and password, which can often include special
characters such as ``@``, ``:``, or ``%``. When connecting via a Unix domain
socket, the socket path may contain special characters such as slashes and
must be encoded. The :php:`rawurlencode() <rawurlencode>` function may be used
to encode constituent parts of the URI.
interface: phpmethod
operation: ~
optional: true
......@@ -17,7 +25,8 @@ type: array
description: |
Specifies additional URI options, such as authentication credentials or query
string parameters. The options specified in ``$uriOptions`` take precedence
over any analogous options present in the ``$uri`` string.
over any analogous options present in the ``$uri`` string and do not need to
be encoded according to `RFC 3986 <http://www.faqs.org/rfcs/rfc3986.html>`_.
Refer to the :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>` extension reference and :manual:`MongoDB
......
ref: error-driver-invalidargumentexception
content: |
:php:`MongoDB\\Driver\\Exception\\InvalidArgumentException
<mongodb-driver-exception-invalidargumentexception>` for errors related to the
parsing of parameters or options at the driver level.
---
ref: error-driver-runtimeexception
content: |
:php:`MongoDB\\Driver\\Exception\\RuntimeException
<mongodb-driver-exception-runtimeexception>` for other errors at the driver
level (e.g. connection errors).
---
ref: error-badmethodcallexception-write-result
content: |
:phpclass:`MongoDB\\Exception\\BadMethodCallException` if this method is
called and the write operation used an unacknowledged :manual:`write concern
</reference/write-concern>`.
---
ref: error-invalidargumentexception
content: |
:phpclass:`MongoDB\\Exception\\InvalidArgumentException` for errors related to
the parsing of parameters or options.
---
ref: error-unexpectedvalueexception
content: |
:phpclass:`MongoDB\\Exception\\UnexpectedValueException` if the command
response from the server was malformed.
---
ref: error-unsupportedexception
content: |
:phpclass:`MongoDB\\Exception\\UnsupportedException` if options are used and
not supported by the selected server (e.g. ``collation``, ``writeConcern``).
...
......@@ -4,28 +4,25 @@ MongoDB PHP Library
.. default-domain:: mongodb
The |php-library| provides a high-level abstraction
around the lower-level `PHP Driver <https://php.net/mongodb>`_, also
known as the ``mongodb`` extension.
While the ``mongodb`` extension provides a limited API for executing
commands, queries, and write operations, the |php-library|
implements an API similar to that of the `legacy PHP driver
<http://php.net/manual/en/book.mongo.php>`_. The library contains
abstractions for client, database, and collection objects, and provides
methods for CRUD operations and common commands such as index and
The |php-library| provides a high-level abstraction around the lower-level
`PHP Driver <https://php.net/mongodb>`_, also known as the ``mongodb``
extension.
While the ``mongodb`` extension provides a limited API for executing commands,
queries, and write operations, the |php-library| implements an API similar to
that of the `legacy PHP driver <http://php.net/manual/en/book.mongo.php>`_. The
library contains abstractions for client, database, and collection objects, and
provides methods for CRUD operations and common commands such as index and
collection management.
If you are developing a PHP application with MongoDB, you should consider
using this library, or another high-level abstraction, instead of the
extension alone.
If you are developing a PHP application with MongoDB, you should consider using
this library, or another high-level abstraction, instead of the extension alone.
For additional information about the MongoDB PHP Library and the
``mongodb`` extension, see the `Architecture Overview
<http://php.net/manual/en/mongodb.overview.php>`_ article in the
extension documentation. `Derick Rethans <http://derickrethans.nl/>`_
has also written a series of blog posts entitled *New MongoDB Drivers
for PHP and HHVM*:
For additional information about the MongoDB PHP Library and the ``mongodb``
extension, see the `Architecture Overview
<http://php.net/manual/en/mongodb.overview.php>`_ article in the extension
documentation. `Derick Rethans <http://derickrethans.nl/>`_ has also written a
series of blog posts entitled *New MongoDB Drivers for PHP and HHVM*:
- `Part One: History <https://derickrethans.nl/new-drivers.html>`_
......@@ -42,26 +39,23 @@ If you are a new MongoDB user, these links should help you become more familiar
with MongoDB and introduce some of the concepts and terms you will encounter in
this documentation:
- `Introduction to CRUD operations in MongoDB
<http://docs.mongodb.org/manual/core/crud-introduction/>`_
- :manual:`Introduction to CRUD operations in MongoDB </core/crud>`
- `What is a MongoDB document?
<http://docs.mongodb.org/manual/core/document/>`_
- :manual:`What is a MongoDB document? </core/document>`
- `MongoDB's *dot notation* for accessing document properties
<http://docs.mongodb.org/manual/core/document/#dot-notation>`_
- :manual:`Dot notation for accessing document properties
</core/document/#dot-notation>`
- `ObjectId: MongoDB's document identifier
<http://docs.mongodb.org/manual/reference/object-id/>`_
- :manual:`ObjectId: MongoDB's document identifier </reference/object-id/>`
.. class:: hidden
.. toctree::
:titlesonly:
Installation </tutorial/install-php-library>
/tutorial
/upgrade
/reference
.. /getting-started
\ No newline at end of file
.. /getting-started
......@@ -6,9 +6,12 @@ Reference
.. toctree::
:titlesonly:
/reference/bson
/reference/class/MongoDBClient
/reference/class/MongoDBDatabase
/reference/class/MongoDBCollection
/reference/class/MongoDBGridFSBucket
/reference/write-result-classes
/reference/enumeration-classes
/reference/exception-classes
......@@ -13,27 +13,52 @@ BSON
Overview
--------
MongoDB stores data records as BSON documents. BSON is a binary
representation of :term:`JSON` documents, though it contains more data
types than JSON. For the BSON spec, see `bsonspec.org <http://bsonspec.org/>`_.
MongoDB stores data records as BSON documents. BSON is a binary representation
of :term:`JSON` documents, though it contains more data types than JSON. For the
BSON spec, see `bsonspec.org <http://bsonspec.org/>`_.
By default, the |php-library| returns BSON documents as
``MongoDB\Model\BSONDocument`` objects and BSON arrays as
``MongoDB\Model\BSONArray`` objects. ``MongoDB\Model\BSONDocument`` and
``MongoDB\Model\BSONArray`` extend PHP's
:php:`ArrayObject <arrayobject>` class and implement the MongoDB PHP
driver's :php:`MongoDB\\BSON\\Serializable <mongodb-bson-serializable>`
and :php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>`
interfaces.
:phpclass:`MongoDB\\Model\\BSONDocument` objects and BSON arrays as
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively.
BSON Classes
------------
.. phpclass:: MongoDB\\Model\\BSONArray
This class extends PHP's :php:`ArrayObject <arrayobject>` class. It also
implements PHP's :php:`JsonSerializable <jsonserializable>` interface and the
driver's :php:`MongoDB\\BSON\\Serializable <mongodb-bson-serializable>` and
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>`
interfaces.
By default, the library will deserialize BSON arrays as instances of this
class. During BSON and JSON serialization, instances of this class will
serialize as an array type (:php:`array_values() <array_values>` is used
internally to numerically reindex the array).
.. phpclass:: MongoDB\\Model\\BSONDocument
This class extends PHP's :php:`ArrayObject <arrayobject>` class. It also
implements PHP's :php:`JsonSerializable <jsonserializable>` interface and the
driver's :php:`MongoDB\\BSON\\Serializable <mongodb-bson-serializable>` and
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>`
interfaces.
By default, the library will deserialize BSON documents as instances of this
class. During BSON and JSON serialization, instances of this class will
serialize as a document type (:php:`object casting
<types.type-juggling#language.types.typecasting>` is used internally).
Type Maps
---------
Most methods that read data from MongoDB support a ``typeMap`` option,
which allows control over how BSON is converted to PHP. Additionally,
Most methods that read data from MongoDB support a ``typeMap`` option, which
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 applies to any supporting methods and selected classes by default.
: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()`).
The :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
:phpclass:`MongoDB\\Collection` classes use the following type map by
......@@ -47,20 +72,28 @@ default:
'root' => 'MongoDB\Model\BSONDocument',
]
Serialization and deserialization of PHP variables into MongoDB
---------------------------------------------------------------
``Persistable`` Classes
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------
The driver's :php:`persistence specification <mongodb.persistence>` outlines how
classes implementing its :php:`MongoDB\\BSON\\Persistable
<mongodb-bson-persistable>` interface are serialized to and deserialized from
BSON. The :php:`Persistable <mongodb-bson-persistable>` interface is analogous
to PHP's :php:`Serializable interface <class.serializable>`.
The PHP driver's :php:`persistence <mongodb.persistence>` specification
specifies how classes implementing :php:`MongoDB\\BSON\\Persistable
<mongodb-bson-persistable>` are serialized and deserialized, and is
analogous to PHP's :php:`Serializable interface <class.serializable>`.
The driver automatically handles serialization and deserialization for classes
implementing the :php:`Persistable <mongodb-bson-persistable>` interface without
requiring the use of the ``typeMap`` option. This is done by encoding the name
of the PHP class in a special property within the BSON document.
The PHP :php:`driver <mongodb>` automatically handles serialization and
deserialization for classes implementing ``MongoDB\BSON\Persistable``
without requiring the use of the ``typeMap`` option.
.. note::
When deserializing a PHP variable from BSON, the encoded class name of a
:php:`Persistable <mongodb-bson-persistable>` object will override any class
specified in the type map, but it will not override ``"array"`` and
``"stdClass"`` or ``"object"``. This is discussed in the
:php:`persistence specification <mongodb.persistence>` but it bears
repeating.
Consider the following class definition:
......@@ -78,12 +111,9 @@ Consider the following class definition:
{
$this->id = new MongoDB\BSON\ObjectID;
$this->name = (string) $name;
// Get current time in milliseconds since the epoch
$msec = floor(microtime(true) * 1000);
$this->createdAt = new MongoDB\BSON\UTCDateTime($msec);
$this->createdAt = new MongoDB\BSON\UTCDateTime;
}
function bsonSerialize()
{
return [
......@@ -92,7 +122,7 @@ Consider the following class definition:
'createdAt' => $this->createdAt,
];
}
function bsonUnserialize(array $data)
{
$this->id = $data['_id'];
......@@ -101,7 +131,7 @@ Consider the following class definition:
}
}
The following constructs a ``Person`` object, inserts it into the
The following example constructs a ``Person`` object, inserts it into the
database, and reads it back as an object of the same type:
.. code-block:: php
......@@ -149,51 +179,47 @@ The same document in the MongoDB shell might display as:
.. note::
:php:`MongoDB\\BSON\\Persistable <mongodb-bson-persistable>` may only be used
for root and embedded BSON documents. BSON arrays are not supported.
for root and embedded BSON documents. It may not be used for BSON arrays.
Emulating the Legacy Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------
The legacy :php:`mongo extension <mongo>` returned both BSON
documents and arrays as PHP arrays. While PHP arrays are convenient to
work with, this behavior was problematic:
The legacy :php:`mongo extension <mongo>` returned both BSON documents and
arrays as PHP arrays. While PHP arrays are convenient to work with, this
behavior was problematic:
- Different BSON types could deserialize to the same PHP value (e.g.
``{"0": "foo"}`` and ``["foo"]``), which made it impossible to infer
the original BSON type.
- Different BSON types could deserialize to the same PHP value (e.g.
``{"0": "foo"}`` and ``["foo"]``), which made it impossible to infer the
original BSON type.
- Numerically-indexed PHP arrays would be serialized as BSON documents
if there was a gap in their key sequence. Such gaps were easily
caused by unsetting a key to remove an element and
forgetting to reindex the array.
- Numerically-indexed PHP arrays would be serialized as BSON documents if there
was a gap in their key sequence. Such gaps were easily caused by unsetting a
key to remove an element and forgetting to numerically reindex the array.
The |php-library|'s ``MongoDB\Model\BSONDocument`` and ``MongoDB\Model\BSONArray``
classes address these
concerns by preserving the BSON type information during serialization
and deserialization; however, some users may still prefer the legacy
behavior. If desired, you can use the ``typeMap`` option to have
the library return everything as a PHP array:
The |php-library|'s :phpclass:`BSONDocument <MongoDB\\Model\\BSONDocument>` and
:phpclass:`BSONArray <MongoDB\\Model\\BSONArray>` classes address these concerns
by preserving the BSON type information during serialization and
deserialization; however, some users may still prefer the legacy behavior. If
desired, you can use the ``typeMap`` option to have the library return
everything as a PHP array:
.. code-block:: php
<?php
$client = new MongoDB\Client(
null,
'mongodb://127.0.0.1/',
[],
['typeMap' => [
'root' => 'array', 'document' => 'array', 'array' => 'array'
[
'typeMap' => [
'array' => 'array',
'document' => 'array',
'root' => 'array',
],
]
);
$document = $client->demo->zips->findOne(
['_id' => '94301'],
['typeMap' => [
'root' => 'array', 'document' => 'array', 'array' => 'array'
],
]
);
$document = $client->demo->zips->findOne(['_id' => '94301']);
var_dump($document);
......
......@@ -15,12 +15,12 @@ Definition
.. phpclass:: MongoDB\\Client
Serves as an entry point for the |php-library|. ``MongoDB\Client``
is the preferred class for connecting to a MongoDB server or cluster
of servers and serves as a gateway for accessing individual
databases and collections. ``MongoDB\Client`` is analogous to the
driver's :php:`MongoDB\\Driver\\Manager <mongodb-driver-manager>`
class, which it composes.
This class serves as an entry point for the |php-library|. It is the
preferred class for connecting to a MongoDB server or cluster of servers and
acts as a gateway for accessing individual databases and collections.
:phpclass:`MongoDB\\Client` is analogous to the driver's
:php:`MongoDB\\Driver\\Manager <mongodb-driver-manager>` class, which it
`composes <https://en.wikipedia.org/wiki/Object_composition>`_.
Methods
-------
......
......@@ -18,24 +18,28 @@ Definition
Provides methods for common operations on collections and documents,
including CRUD operations and index management.
You can construct collections directly using the PHP extension's
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` class, select
a collection from the |php-library|'s :phpclass:`MongoDB\\Client` or
:phpclass:`MongoDB\\Database` classes, or create a collection from an
existing collection using the
:phpmethod:`withOptions() <MongoDB\\Collection::withOptions>` clone method.
You can construct collections directly using the driver's
:php:`MongoDB\\Driver\\Manager <class.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
:phpmethod:`withOptions() <MongoDB\\Collection::withOptions>` method.
:phpclass:`MongoDB\\Collection` supports the :php:`readConcern
<mongodb-driver-readconcern>`, :php:`readPreference
<mongodb-driver-readpreference>`, :php:`typeMap
<manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`,
and :php:`writeConcern <mongodb-driver-writeconcern>` options.
If you omit an option, the collection inherits the value from the
Manager constructor argument or the Database object used to select
the collection.
and :php:`writeConcern <mongodb-driver-writeconcern>` options. If you omit an
option, the collection inherits the value from the :php:`Manager
<mongodb-driver-manager>` constructor argument or the :phpclass:`Client
<MongoDB\\Client>` or :phpclass:`Database <MongoDB\\Database>` object used to
select the collection.
Operations within the :phpclass:`MongoDB\\Collection` class inherit the
Collection's options.
collection's options.
Type Map Limitations
--------------------
The :manual:`aggregate </reference/command/aggregate>` (when not using a
cursor), :manual:`distinct </reference/command/distinct>`, and
......@@ -49,7 +53,6 @@ Definition
methods return BSON documents as `stdClass` objects and BSON arrays as
arrays.
Methods
-------
......
......@@ -10,34 +10,33 @@ MongoDB\\Database Class
:depth: 1
:class: singlecol
Definition
----------
.. phpclass:: MongoDB\\Database
Provides methods for common operations on a database,
such as executing database commands and managing collections.
Provides methods for common operations on a database, such as executing
database commands and managing collections.
You can construct a database directly using the PHP extension's
You can construct a database directly using the driver's
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` class or
select a database from the |php-library|'s :phpclass:`MongoDB\\Client` class.
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() <MongoDB\\Database::withOptions>`
method.
:phpclass:`MongoDB\\Database` supports the :php:`readConcern
<mongodb-driver-readconcern>`, :php:`readPreference
<mongodb-driver-readpreference>`, :php:`typeMap
<manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`,
and :php:`writeConcern <mongodb-driver-writeconcern>` options.
If you omit an option, the database inherits the value from the
Manager constructor argument or the Client object used to select
the database.
and :php:`writeConcern <mongodb-driver-writeconcern>` options. If you omit an
option, the database inherits the value from the :php:`Manager
<mongodb-driver-manager>` constructor argument or the :phpclass:`Client
<MongoDB\\Client>` object used to select the database.
Operations within the :phpclass:`MongoDB\\Database` class inherit the
Database's options.
.. _database-methods:
Methods
-------
......
......@@ -15,18 +15,18 @@ Definition
.. phpclass:: MongoDB\\GridFS\\Bucket
:manual:`GridFS </core/gridfs/>` is a specification for storing and
retrieving files in MongoDB. GridFS uses two collections to store files. One
collection stores the file chunks (e.g. ``fs.chunks``), and the other stores
file metadata (e.g. ``fs.files``). The :phpclass:`MongoDB\\GridFS\\Bucket`
class provides an interface around these collections for working with the
files as PHP :php:`Streams <stream>`.
You can construct a GridFS bucket using the PHP extension's
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` class, or
select a bucket from the |php-library|'s :phpclass:`MongoDB\\Database` class
via the :phpmethod:`selectGridFSBucket()
<MongoDB\\Database::selectGridFSBucket>` method.
:manual:`GridFS </core/gridfs>` is a specification for storing and retrieving
files in MongoDB. GridFS uses two collections to store files. One collection
stores the file chunks (e.g. ``fs.chunks``), and the other stores file
metadata (e.g. ``fs.files``). The :phpclass:`MongoDB\\GridFS\\Bucket` class
provides an interface around these collections for working with the files as
PHP :php:`Streams <stream>`.
You can construct a GridFS bucket using the driver's
:php:`Manager <class.mongodb-driver-manager>` class, or select a bucket from
the library's :phpclass:`MongoDB\\Database` class via the
:phpmethod:`selectGridFSBucket() <MongoDB\\Database::selectGridFSBucket>`
method.
Methods
-------
......
===================
Enumeration Classes
===================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
MongoDB\\Model\\CollectionInfo
------------------------------
Definition
~~~~~~~~~~
.. phpclass:: MongoDB\\Model\\CollectionInfo
This class models information about a collection. Instances of this class are
returned by traversing a :phpclass:`MongoDB\\Model\\CollectionInfoIterator`,
which is returned by :phpmethod:`MongoDB\\Database::listCollections()`.
Methods
~~~~~~~
.. toctree::
:titlesonly:
/reference/method/MongoDBModelCollectionInfo-getCappedMax
/reference/method/MongoDBModelCollectionInfo-getCappedSize
/reference/method/MongoDBModelCollectionInfo-getName
/reference/method/MongoDBModelCollectionInfo-getOptions
/reference/method/MongoDBModelCollectionInfo-isCapped
----
MongoDB\\Model\\CollectionInfoIterator
--------------------------------------
Definition
~~~~~~~~~~
.. phpclass:: MongoDB\\Model\\CollectionInfoIterator
This interface extends PHP's :php:`Iterator <manual/en/class.iterator.php>`
interface. An instance of this interface is returned by
:phpmethod:`MongoDB\\Database::listCollections()`.
Methods
~~~~~~~
This interface adds no new methods to :php:`Iterator
<manual/en/class.iterator.php>`, but specifies that :php:`current()
<manual/en/iterator.current.php>` will return an instance of
:phpclass:`MongoDB\\Model\\CollectionInfo`.
----
MongoDB\\Model\\DatabaseInfo
----------------------------
Definition
~~~~~~~~~~
.. phpclass:: MongoDB\\Model\\DatabaseInfo
This class models information about a database. Instances of this class are
returned by traversing a :phpclass:`MongoDB\\Model\\DatabaseInfoIterator`,
which is returned by :phpmethod:`MongoDB\\Client::listDatabases()`.
Methods
~~~~~~~
.. toctree::
:titlesonly:
/reference/method/MongoDBModelDatabaseInfo-getName
/reference/method/MongoDBModelDatabaseInfo-getSizeOnDisk
/reference/method/MongoDBModelDatabaseInfo-isEmpty
----
MongoDB\\Model\\DatabaseInfoIterator
------------------------------------
Definition
~~~~~~~~~~
.. phpclass:: MongoDB\\Model\\DatabaseInfoIterator
This interface extends PHP's :php:`Iterator <manual/en/class.iterator.php>`
interface. An instance of this interface is returned by
:phpmethod:`MongoDB\\Client::listDatabases()`.
Methods
~~~~~~~
This interface adds no new methods to :php:`Iterator
<manual/en/class.iterator.php>`, but specifies that :php:`current()
<manual/en/iterator.current.php>` will return an instance of
:phpclass:`MongoDB\\Model\\DatabaseInfo`.
----
MongoDB\\Model\\IndexInfo
-------------------------
.. phpclass:: MongoDB\\Model\\IndexInfo
This class models information about an index. Instances of this class are
returned by traversing a :phpclass:`MongoDB\\Model\\IndexInfoIterator`,
which is returned by :phpmethod:`MongoDB\\Collection::listIndexes()`.
This class implements PHP's :php:`ArrayAccess <arrayaccess>` interface. This
provides a mechanism for accessing index fields for which there exists no
helper method. :php`isset() <isset>` may be used to check for the existence
of a field before accessing it with ``[]``.
.. note::
The :phpclass:`MongoDB\\Model\\IndexInfo` class is immutable. Attempting
to modify it via the :php:`ArrayAccess <arrayaccess>` interface will
result in a :phpclass:`MongoDB\\Exception\\BadMethodCallException`.
Methods
~~~~~~~
.. toctree::
:titlesonly:
/reference/method/MongoDBModelIndexInfo-getKey
/reference/method/MongoDBModelIndexInfo-getName
/reference/method/MongoDBModelIndexInfo-getNamespace
/reference/method/MongoDBModelIndexInfo-getVersion
/reference/method/MongoDBModelIndexInfo-isSparse
/reference/method/MongoDBModelIndexInfo-isTtl
/reference/method/MongoDBModelIndexInfo-isUnique
----
MongoDB\\Model\\IndexInfoIterator
---------------------------------
Definition
~~~~~~~~~~
.. phpclass:: MongoDB\\Model\\IndexInfoIterator
This interface extends PHP's :php:`Iterator <manual/en/class.iterator.php>`
interface. An instance of this interface is returned by
:phpmethod:`MongoDB\\Collection::listIndexes()`.
Methods
~~~~~~~
This interface adds no new methods to :php:`Iterator
<manual/en/class.iterator.php>`, but specifies that :php:`current()
<manual/en/iterator.current.php>` will return an instance of
:phpclass:`MongoDB\\Model\\IndexInfo`.
=================
Exception Classes
=================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
MongoDB\\Exception\\BadMethodCallException
------------------------------------------
.. phpclass:: MongoDB\\Exception\\BadMethodCallException
This exception is thrown when an unsupported method is invoked on an object.
For example, using an unacknowledged write concern with
:phpmethod:`MongoDB\\Collection::insertMany()` will return a
:phpclass:`MongoDB\\InsertManyResult` object. It is a logical error to call
:phpmethod:`MongoDB\\InsertManyResult::getInsertedCount()`, since the number
of inserted documents can only be determined from the response of an
acknowledged write operation.
This class extends PHP's :php:`BadMethodCallException
<badmethodcallexception>` class and implements the library's
:phpclass:`Exception <MongoDB\\Exception\\Exception>` interface.
----
MongoDB\\Exception\\InvalidArgumentException
--------------------------------------------
.. phpclass:: MongoDB\\Exception\\InvalidArgumentException
Thrown for errors related to the parsing of parameters or options within the
library.
This class extends the driver's :php:`InvalidArgumentException
<mongodb-driver-exception-invalidargumentexception>` class and implements the
library's :phpclass:`Exception <MongoDB\\Exception\\Exception>` interface.
----
MongoDB\\Exception\\UnexpectedValueException
--------------------------------------------
.. phpclass:: MongoDB\\Exception\\UnexpectedValueException
This exception is thrown when a command response from the server is
malformed or not what the library expected. This exception means that an
assertion in some operation, which abstracts a database command, has failed.
It may indicate a corrupted BSON response or bug in the server, driver, or
library.
This class extends the driver's :php:`UnexpectedValueException
<mongodb-driver-exception-unexpectedvalueexception>` class and implements the
library's :phpclass:`Exception <MongoDB\\Exception\\Exception>` interface.
----
MongoDB\\Exception\\UnsupportedException
----------------------------------------
.. phpclass:: MongoDB\\Exception\\UnsupportedException
This exception is thrown if an option is used and not supported by the
selected server. It is used sparingly in cases where silently ignoring the
unsupported option might otherwise lead to unexpected behavior.
For example, the ``collation`` option for
:phpmethod:`MongoDB\\Collection::deleteOne()` is only supported by
MongoDB 3.4+. Since collation determines how a document is matched, silently
ignoring the option for an older server version could result in an
unintended document being deleted.
This class extends the library's :phpclass:`RuntimeException
<MongoDB\\Exception\\RuntimeException>` class and implements the
library's :phpclass:`Exception <MongoDB\\Exception\\Exception>` interface.
.. note::
Unlike :phpclass:`InvalidArgumentException
<MongoDB\\Exception\\InvalidArgumentException>`, which may be thrown when
an operation's parameters and options are parsed during construction, the
selected server is not known until an operation is executed.
----
MongoDB\\Exception\\Exception
-----------------------------
.. phpclass:: MongoDB\\Exception\\Exception
This interface extends the driver's :php:`Exception
<mongodb-driver-exception-exception>` interface and is implemented by all
exception classes within the library.
----
MongoDB\\Exception\\RuntimeException
------------------------------------
.. phpclass:: MongoDB\\Exception\\RuntimeException
This class extends the driver's :php:`RuntimeException
<mongodb-driver-exception-runtimeexception>` class, which in turn extends
PHP's :php:`RuntimeException <runtimeexception>` class.
===========================================
MongoDB\\BulkWriteResult::getDeletedCount()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getDeletedCount()
Return the total number of documents that were deleted by all delete
operations in the bulk write.
.. code-block:: php
function getDeletedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The total number of documents that were deleted by all delete operations in the
bulk write.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getDeletedCount()
<manual/en/mongodb-driver-writeresult.getdeletedcount.php>`
============================================
MongoDB\\BulkWriteResult::getInsertedCount()
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getInsertedCount()
Return the total number of documents that were inserted by all insert
operations in the bulk write.
.. code-block:: php
function getInsertedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The total number of documents that were inserted by all insert operations in the
bulk write.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getInsertedCount()
<manual/en/mongodb-driver-writeresult.getinsertedcount.php>`
==========================================
MongoDB\\BulkWriteResult::getInsertedIds()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getInsertedIds()
Return a map of IDs (i.e. ``_id`` field values) for documents that were
inserted by all insert operations in the bulk write.
.. code-block:: php
function getInsertedIds(): array
Since IDs are created by the driver, this method may be called irrespective
of whether the write was acknowledged.
Return Values
-------------
A map of IDs (i.e. ``_id`` field values) for documents that were inserted by all
insert operations in the bulk write.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to inserting (i.e. the driver did
not generate an ID), the index will contain its ``_id`` field value. Any
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
<class.mongodb-bson-objectid>` instance.
===========================================
MongoDB\\BulkWriteResult::getMatchedCount()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getMatchedCount()
Return the total number of documents that were matched by all update and
replace operations in the bulk write.
.. code-block:: php
function getMatchedCount(): integer
This method should only be called if the write was acknowledged.
.. note::
If an update/replace operation results in no change to the document
(e.g. setting the value of a field to its current value), the matched
count may be greater than the value returned by
:phpmethod:`getModifiedCount()
<MongoDB\\BulkWriteResult::getModifiedCount()>`.
Return Values
-------------
The total number of documents that were matched by all update and replace
operations in the bulk write.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :phpmethod:`MongoDB\\BulkWriteResult::getModifiedCount()`
- :php:`MongoDB\\Driver\\WriteResult::getMatchedCount()
<manual/en/mongodb-driver-writeresult.getmatchedcount.php>`
============================================
MongoDB\\BulkWriteResult::getModifiedCount()
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getModifiedCount()
Return the total number of documents that were modified by all update and
replace operations in the bulk write.
.. code-block:: php
function getModifiedCount(): integer|null
This method should only be called if the write was acknowledged.
.. note::
If an update/replace operation results in no change to the document
(e.g. setting the value of a field to its current value), the modified
count may be less than the value returned by :phpmethod:`getMatchedCount()
<MongoDB\\BulkWriteResult::getMatchedCount()>`.
Return Values
-------------
The total number of documents that were modified by all update and replace
operations in the bulk write.
The modified count is not available on versions of MongoDB before 2.6, which
used the legacy wire protocol version (i.e. ``OP_UPDATE``). If this is the case,
the modified count will be ``null``.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :phpmethod:`MongoDB\\BulkWriteResult::getMatchedCount()`
- :php:`MongoDB\\Driver\\WriteResult::getModifiedCount()
<manual/en/mongodb-driver-writeresult.getmodifiedcount.php>`
============================================
MongoDB\\BulkWriteResult::getUpsertedCount()
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getUpsertedCount()
Return the total number of documents that were upserted by all update and
replace operations in the bulk write.
.. code-block:: php
function getUpsertedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The total number of documents that were upserted by all update and replace
operations in the bulk write.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getUpsertedCount()
<manual/en/mongodb-driver-writeresult.getupsertedcount.php>`
==========================================
MongoDB\\BulkWriteResult::getUpsertedIds()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::getUpsertedIds()
Return a map of IDs (i.e. ``_id`` field values) for documents that were
upserted by all update and replace operations in the bulk write.
.. code-block:: php
function getUpsertedIds(): array
Return Values
-------------
A map of IDs (i.e. ``_id`` field values) for documents that were upserted by all
update and replace operations in the bulk write.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to upserting (i.e. the server did
not generate an ID), the index will contain its ``_id`` field value. Any
server-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
<class.mongodb-bson-objectid>` instance.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getUpsertedIds()
<manual/en/mongodb-driver-writeresult.getupsertedids.php>`
==========================================
MongoDB\\BulkWriteResult::isAcknowledged()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\BulkWriteResult::isAcknowledged()
Return whether the write was acknowledged.
.. code-block:: php
function isAcknowledged(): boolean
Return Values
-------------
A boolean indicating whether the write was acknowledged.
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::isAcknowledged()
<manual/en/mongodb-driver-writeresult.isacknowledged.php>`
- :manual:`Write Concern </reference/write-concern>` in the MongoDB manual
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-dropDatabase-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on
the ``typeMap`` option.
An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -62,8 +70,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::drop()`
- :manual:`dropDatabase </reference/command/dropDatabase>` command reference
in the MongoDB manual
- :phpmethod:`MongoDB\\Database::drop()`
- :manual:`dropDatabase </reference/command/dropDatabase>` command reference in
the MongoDB manual
......@@ -23,11 +23,13 @@ Definition
function getManager(): MongoDB\Manager
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::getManager()`
- :phpmethod:`MongoDB\\Database::getManager()`
- :phpmethod:`MongoDB\\Collection::getManager()`
- :phpmethod:`MongoDB\\Database::getManager()`
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-listDatabases-option.rst
:returns:
Return Values
-------------
A traversable :phpclass:`MongoDB\\Model\DatabaseInfoIterator`, which
contains an :phpclass:`MongoDB\\Model\DatabaseInfo` object for each
database on the server.
A traversable :phpclass:`MongoDB\\Model\\DatabaseInfoIterator`, which contains
a :phpclass:`MongoDB\\Model\\DatabaseInfo` object for each database on the
server.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -69,7 +77,8 @@ The output would then resemble::
bool(false)
}
.. seealso::
See Also
--------
- :manual:`listDatabases </reference/command/listDatabases>` command
reference in the MongoDB manual
- :manual:`listDatabases </reference/command/listDatabases>` command reference
in the MongoDB manual
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-selectCollection-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Collection` object.
A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -70,7 +76,8 @@ with a custom read preference:
]
);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::__construct()`
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Collection::__construct()`
- :phpmethod:`MongoDB\\Database::selectCollection()`
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-selectDatabase-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Database` object.
A :phpclass:`MongoDB\\Database` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -69,7 +75,8 @@ preference:
]
);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Client::__get()`
- :phpmethod:`MongoDB\\Database::__construct()`
- :phpmethod:`MongoDB\\Client::__get()`
- :phpmethod:`MongoDB\\Database::__construct()`
......@@ -29,9 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-construct-driverOptions.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
Connecting to a Replica Set
~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you do not specify a ``$uri`` value, the driver connects to a standalone
:program:`mongod` on ``127.0.0.1`` via port ``27017``. The following example
demonstrates how to connect to a replica set with a custom read preference:
......@@ -47,6 +57,48 @@ demonstrates how to connect to a replica set with a custom read preference:
]
);
Connecting with SSL and Authentication
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following example demonstrates how to connect to a MongoDB replica set with
SSL and authentication, as is used for `MongoDB Atlas
<https://cloud.mongodb.com/?jmp=docs>`_:
.. code-block:: php
<?php
$client = new MongoDB\Client(
'mongodb://myUsername:myPassword@rs1.example.com,rs2.example.com/?ssl=true&replicaSet=myReplicaSet&authSource=admin'
);
Alternatively, the authentication credentials and URI parameters may be
specified in the constructor's ``$uriOptions`` parameter:
.. code-block:: php
<?php
$client = new MongoDB\Client(
'mongodb://rs1.example.com,rs2.example.com/'
[
'username' => 'myUsername',
'password' => 'myPassword',
'ssl' => true,
'replicaSet' => 'myReplicaSet',
'authSource' => 'admin',
],
);
The driver supports additional :php:`SSL options
<mongodb-driver-manager.construct#mongodb-driver-manager.construct-driveroptions>`,
which may be specified in the constructor's ``$driverOptions`` parameter. Those
options are covered in the :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>` documentation.
Specifying a Custom Type Map
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, the |php-library| deserializes BSON documents and arrays
as :phpclass:`MongoDB\\Model\\BSONDocument` and
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The following
......@@ -69,7 +121,10 @@ array, as was done in the legacy :php:`mongo extension <mongo>`.
]
);
.. seealso::
See Also
--------
- :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>`
- :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>`
- :manual:`Connection String URI Format </reference/connection-string>` in the
MongoDB manual
......@@ -27,9 +27,10 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-get-param.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Database` object.
A :phpclass:`MongoDB\\Database` object.
Behavior
--------
......@@ -60,8 +61,9 @@ The following example selects the ``demo`` and ``another-app`` databases:
$demo = $client->demo;
$anotherApp = $client->{'another-app'};
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Database::__construct()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Database::__construct()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual
......@@ -16,7 +16,7 @@ Definition
.. phpmethod:: MongoDB\\Collection::aggregate()
Executes an :manual:`aggregation framework pipeline
</core/aggregation-pipeline/>` operation on the collection.
</core/aggregation-pipeline>` operation on the collection.
.. code-block:: php
......@@ -30,11 +30,20 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-aggregate-option.rst
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or
:php:`ArrayIterator <arrayiterator>` object. In both cases, the return
value will be :php:`Traversable <traversable>`.
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or
:php:`ArrayIterator <arrayiterator>` object. In both cases, the return value
will be :php:`Traversable <traversable>`.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. _php-agg-method-behavior:
......@@ -59,9 +68,10 @@ value will be :php:`Traversable <traversable>`.
.. todo: add examples
.. seealso::
See Also
--------
- :manual:`aggregate </reference/command/aggregate>` command reference in the
MongoDB manual
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>`
documentation in the MongoDB Manual
- :manual:`aggregate </reference/command/aggregate>` command reference in the
MongoDB manual
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>` documentation in
the MongoDB Manual
......@@ -29,21 +29,29 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-bulkWrite-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\BulkWriteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\BulkWriteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
.. todo: add output and examples
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. seealso::
.. todo: add output and examples
- :phpmethod:`MongoDB\\Collection::deleteMany()`
- :phpmethod:`MongoDB\\Collection::deleteOne()`
- :phpmethod:`MongoDB\\Collection::insertMany()`
- :phpmethod:`MongoDB\\Collection::insertOne()`
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :doc:`/tutorial/crud`
See Also
--------
- :phpmethod:`MongoDB\\Collection::deleteMany()`
- :phpmethod:`MongoDB\\Collection::deleteOne()`
- :phpmethod:`MongoDB\\Collection::insertMany()`
- :phpmethod:`MongoDB\\Collection::insertOne()`
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :doc:`/tutorial/crud`
......@@ -29,13 +29,23 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-count-option.rst
:returns:
Return Values
-------------
The number of documents matching the filter criteria.
The number of documents matching the filter criteria.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add output and examples
.. seealso::
See Also
--------
- :manual:`count </reference/command/count>` command reference in the MongoDB
manual
- :manual:`count </reference/command/count>` command reference in the MongoDB
manual
......@@ -34,9 +34,17 @@ Definition
:manual:`createIndexes </reference/command/createIndexes>` command reference
in the MongoDB manual.
:returns:
Return Values
-------------
The name of the created index as a string.
The name of the created index as a string.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -91,10 +99,11 @@ The output would then resemble::
string(9) "borough_1"
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndexes()`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>` command
reference in the MongoDB manual
- :manual:`Index </indexes>` documentation in the MongoDB Manual
- :phpmethod:`MongoDB\\Collection::createIndexes()`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>` command reference
in the MongoDB manual
- :manual:`Index </indexes>` documentation in the MongoDB Manual
......@@ -29,9 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-createIndexes-option.rst
:returns:
Return Values
-------------
The names of the created indexes as an array of strings.
The names of the created indexes as an array of strings.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
``$indexes`` parameter
----------------------
......@@ -82,10 +90,11 @@ The output would then resemble::
string(9) "geo_index"
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>` command
reference in the MongoDB manual
- :manual:`Index </indexes>` documentation in the MongoDB Manual
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>` command reference
in the MongoDB manual
- :manual:`Index </indexes>` documentation in the MongoDB Manual
......@@ -29,11 +29,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-deleteMany-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -58,10 +65,11 @@ The output would then resemble::
Deleted 2 document(s)
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::deleteOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`delete </reference/command/delete` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::deleteOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`delete </reference/command/delete` command reference in the MongoDB
manual
......@@ -31,11 +31,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-deleteOne-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -60,10 +67,11 @@ The output would then resemble::
Deleted 1 document(s)
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::deleteMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`delete command reference </reference/command/delete`
in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::deleteMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`delete </reference/command/delete` command reference in the MongoDB
manual
......@@ -29,9 +29,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-distinct-option.rst
:returns:
Return Values
-------------
An array of the distinct values.
An array of the distinct values.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -241,7 +250,8 @@ The output would then resemble::
string(29) "Vietnamese/Cambodian/Malaysia"
}
.. seealso::
See Also
--------
- :manual:`distinct </reference/command/distinct>` command reference in the
MongoDB manual
- :manual:`distinct </reference/command/distinct>` command reference in the
MongoDB manual
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-drop-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on the
``typeMap`` option.
An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -65,8 +73,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::dropCollection()`
- :manual:`drop </reference/command/drop>` command reference in the MongoDB
manual
- :phpmethod:`MongoDB\\Database::dropCollection()`
- :manual:`drop </reference/command/drop>` command reference in the MongoDB
manual
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on
the ``typeMap`` option.
An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -63,10 +71,11 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::dropIndexes()`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command reference
in the MongoDB manual
- :manual:`Index documentation </indexes>` in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::dropIndexes()`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command reference in
the MongoDB manual
- :manual:`Index documentation </indexes>` in the MongoDB manual
......@@ -30,11 +30,19 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on
the ``typeMap`` option.
An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -66,10 +74,11 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::dropIndex()`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command reference
in the MongoDB manual
- :manual:`Index documentation </indexes>` in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::dropIndex()`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command reference in
the MongoDB manual
- :manual:`Index documentation </indexes>` in the MongoDB manual
......@@ -29,9 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-find-option.rst
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -147,8 +155,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::findOne()`
- :manual:`find </reference/command/find>` command reference in the MongoDB
manual
- :phpmethod:`MongoDB\\Collection::findOne()`
- :manual:`find </reference/command/find>` command reference in the MongoDB
manual
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-findOne-option.rst
:returns:
Return Values
-------------
An array or object for the :term:`first document <natural order>` document
that matched the query, or ``null`` if no document matched the query. The
return type will depend on the ``typeMap`` option.
An array or object for the :term:`first document <natural order>` document that
matched the query, or ``null`` if no document matched the query. The return type
will depend on the ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -82,8 +90,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::find()`
- :manual:`find </reference/command/find>` command reference in the MongoDB
manual
- :phpmethod:`MongoDB\\Collection::find()`
- :manual:`find </reference/command/find>` command reference in the MongoDB
manual
......@@ -31,10 +31,19 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndDelete.rst
:returns:
Return Values
-------------
An object for the document that was deleted, or ``null`` if no document
matched the query.
An object for the document that was deleted, or ``null`` if no document matched
the query.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -77,9 +86,10 @@ The output would then resemble::
string(8) "40375376"
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::findOneAndReplace()`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate()`
- :manual:`findAndModify </reference/command/findAndModify>` command
reference in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::findOneAndReplace()`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate()`
- :manual:`findAndModify </reference/command/findAndModify>` command reference
in the MongoDB manual
......@@ -31,12 +31,20 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndReplace.rst
:returns:
Return Values
-------------
An object for either the original or the replaced document, depending on
the specified value of the ``returnDocument`` option. By default, the
original document is returned. If no document matched the query, ``null``
is returned.
An object for either the original or the replaced document, depending on the
specified value of the ``returnDocument`` option. By default, the original
document is returned. If no document matched the query, ``null`` is returned.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -124,9 +132,10 @@ The output would then resemble::
string(9) "999999999"
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::findOneAndDelete()`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate()`
- :manual:`findAndModify </reference/command/findAndModify>` command
reference in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::findOneAndDelete()`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate()`
- :manual:`findAndModify </reference/command/findAndModify>` command reference
in the MongoDB manual
......@@ -31,12 +31,20 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndUpdate.rst
:returns:
Return Values
-------------
An object for either the original or the updated document, depending on
the specified value of the ``returnDocument`` option. By default, the
original document is returned. If no document matched the query, ``null``
is returned.
An object for either the original or the updated document, depending on the
specified value of the ``returnDocument`` option. By default, the original
document is returned. If no document matched the query, ``null`` is returned.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -88,9 +96,10 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::findOneAndDelete()`
- :phpmethod:`MongoDB\\Collection::findOneAndReplace()`
- :manual:`findAndModify </reference/command/findAndModify>` command
reference in the MongoDB manual
- :phpmethod:`MongoDB\\Collection::findOneAndDelete()`
- :phpmethod:`MongoDB\\Collection::findOneAndReplace()`
- :manual:`findAndModify </reference/command/findAndModify>` command reference
in the MongoDB manual
......@@ -21,9 +21,10 @@ Definition
function getCollectionName(): string
:returns:
Return Values
-------------
The name of this collection as a string.
The name of this collection as a string.
Example
-------
......@@ -43,7 +44,8 @@ The output would then resemble::
zips
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
......@@ -21,9 +21,10 @@ Definition
function getDatabaseName(): string
:returns:
Return Values
-------------
The name of the database containing this collection as a string.
The name of the database containing this collection as a string.
Example
-------
......@@ -43,8 +44,9 @@ The output would then resemble::
demo
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
......@@ -23,11 +23,13 @@ Definition
function getManager(): MongoDB\Manager
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Client::getManager()`
- :phpmethod:`MongoDB\\Database::getManager()`
- :phpmethod:`MongoDB\\Client::getManager()`
- :phpmethod:`MongoDB\\Database::getManager()`
......@@ -22,9 +22,10 @@ Definition
function getNamespace(): string
:returns:
Return Values
-------------
The namespace of this collection as a string.
The namespace of this collection as a string.
Example
-------
......@@ -44,7 +45,8 @@ The output would then resemble::
demo.zips
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
......@@ -29,11 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-insertMany-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\InsertManyResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\InsertManyResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -84,10 +90,11 @@ The output would then resemble::
.. end-crud-include
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::insertOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::insertOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference in the MongoDB
manual
......@@ -29,11 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-insertOne-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\InsertOneResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\InsertOneResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -69,10 +75,11 @@ The output would then resemble::
.. end-crud-include
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::insertMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::insertMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference in the MongoDB
manual
......@@ -29,11 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-option.rst
:returns:
Return Values
-------------
A traversable :phpclass:`MongoDB\\Model\IndexInfoIterator`, which
contains an :phpclass:`MongoDB\\Model\IndexInfo` object for each index for
the collection.
A traversable :phpclass:`MongoDB\\Model\\IndexInfoIterator`, which contains a
:phpclass:`MongoDB\\Model\\IndexInfo` object for each index for the collection.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -93,12 +99,13 @@ The output would then resemble::
string(19) "example.restaurants"
}
.. seealso::
See Also
--------
- :doc:`/tutorial/indexes`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
- :manual:`Index documentation </core/indexes>` in the MongoDB manual
- `Enumerating Collections
<https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst>`_
specification
- :doc:`/tutorial/indexes`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
- :manual:`Index documentation </core/indexes>` in the MongoDB manual
- `Enumerating Collections
<https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst>`_
specification
......@@ -31,11 +31,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-replaceOne-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -68,11 +75,12 @@ The output would then resemble::
Matched 1 document(s)
Modified 1 document(s)
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the MongoDB
manual
......@@ -29,11 +29,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-updateMany-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -58,11 +65,12 @@ The output would then resemble::
Matched 5656 document(s)
Modified 5656 document(s)
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the MongoDB
manual
......@@ -31,11 +31,18 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-updateOne-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples
--------
......@@ -60,11 +67,12 @@ The output would then resemble::
Matched 1 document(s)
Modified 1 document(s)
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the
MongoDB manual
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference in the MongoDB
manual
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Collection` object.
A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Example
-------
......@@ -49,6 +55,7 @@ preference:
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::__construct()`
- :phpmethod:`MongoDB\\Collection::__construct()`
......@@ -29,6 +29,11 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-construct-option.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -40,9 +45,10 @@ options from that object.
.. todo: add an example
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::withOptions()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Database::__get()`
- :phpmethod:`MongoDB\\Collection::withOptions()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Database::__get()`
......@@ -29,9 +29,16 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-command-option.rst
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -138,11 +145,11 @@ The output would resemble::
}
}
.. seealso::
See Also
--------
- :doc:`/tutorial/commands`
- :manual:`Database Commands </reference/command>` in the
MongoDB manual
- :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>`
- :php:`MongoDB\\Driver\\Manager::executeCommand()
<manual/en/mongodb-driver-manager.executecommand.php>`
- :doc:`/tutorial/commands`
- :manual:`Database Commands </reference/command>` in the MongoDB manual
- :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>`
- :php:`MongoDB\\Driver\\Manager::executeCommand()
<manual/en/mongodb-driver-manager.executecommand.php>`
......@@ -25,7 +25,7 @@ Definition
collection in a command, such as when inserting a document into a new
collection. You may also explicitly create a collection with specific options
using the :phpmethod:`MongoDB\\Database::createCollection()` method, or using
:manual:`db.createCollection() </reference/method/db.createCollection/>` in
:manual:`db.createCollection() </reference/method/db.createCollection>` in
the :program:`mongo` shell.
Explicitly creating collections enables you to create
......@@ -47,10 +47,18 @@ Definition
:manual:`create </reference/command/create>` command reference in the MongoDB
manual for compatibility considerations.
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`create
</reference/command/create>` command.
An array or object with the result document of the :manual:`create
</reference/command/create>` command.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -83,8 +91,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :manual:`create </reference/command/create>` command reference in the MongoDB
manual
- :manual:`db.createCollection() </reference/method/db.createCollection/>`
- :manual:`create </reference/command/create>` command reference in the MongoDB
manual
- :manual:`db.createCollection() </reference/method/db.createCollection>`
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-drop-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on
the ``typeMap`` option.
An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -62,8 +70,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Client::dropDatabase()`
- :manual:`dropDatabase </reference/command/dropDatabase>` command reference
in the MongoDB manual
- :phpmethod:`MongoDB\\Client::dropDatabase()`
- :manual:`dropDatabase </reference/command/dropDatabase>` command reference in
the MongoDB manual
......@@ -29,11 +29,19 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-dropCollection-option.rst
:returns:
Return Values
-------------
An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on
the ``typeMap`` option.
An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on the
``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
......@@ -64,8 +72,9 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::drop()`
- :manual:`drop </reference/command/drop>` command reference in the MongoDB
manual
- :phpmethod:`MongoDB\\Collection::drop()`
- :manual:`drop </reference/command/drop>` command reference in the MongoDB
manual
......@@ -21,9 +21,10 @@ Definition
function getDatabaseName(): string
:returns:
Return Values
-------------
The name of this database as a string.
The name of this database as a string.
Example
-------
......
......@@ -23,11 +23,13 @@ Definition
function getManager(): MongoDB\Manager
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
A :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Client::getManager()`
- :phpmethod:`MongoDB\\Collection::getManager()`
- :phpmethod:`MongoDB\\Client::getManager()`
- :phpmethod:`MongoDB\\Collection::getManager()`
......@@ -29,11 +29,12 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-listCollections-option.rst
:returns:
Return Values
-------------
A traversable :phpclass:`MongoDB\\Model\CollectionInfoIterator`, which
contains an :phpclass:`MongoDB\\Model\CollectionInfo` object for each
collection in the database.
A traversable :phpclass:`MongoDB\\Model\\CollectionInfoIterator`, which contains
a :phpclass:`MongoDB\\Model\\CollectionInfo` object for each collection in the
database.
Example
-------
......@@ -110,10 +111,11 @@ The output would then resemble::
}
}
.. seealso::
See Also
--------
- :manual:`listCollections </reference/command/listCollections` command
reference in the MongoDB manual
- `Enumerating Collections
<https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst>`_
specification
- :manual:`listCollections </reference/command/listCollections` command
reference in the MongoDB manual
- `Enumerating Collections
<https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst>`_
specification
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Collection` object.
A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -69,8 +75,9 @@ database with a custom read preference:
]
);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::__get()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Collection::__construct()`
- :phpmethod:`MongoDB\\Database::__get()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Collection::__construct()`
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-selectGridFSBucket-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\GridFS\\Bucket` object.
A :phpclass:`MongoDB\\GridFS\\Bucket` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -68,6 +74,7 @@ database with a custom read preference:
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::__construct()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::__construct()`
......@@ -29,9 +29,15 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-withOptions-option.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Database` object.
A :phpclass:`MongoDB\\Database` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Example
-------
......@@ -49,6 +55,7 @@ preference:
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]);
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::__construct()`
- :phpmethod:`MongoDB\\Database::__construct()`
......@@ -29,6 +29,11 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
......@@ -37,8 +42,9 @@ the :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object. If
you select the Database from a :phpclass:`Client <MongoDB\\Client>` object, the
Database inherits its options from that object.
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::withOptions()`
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Client::__get()`
- :phpmethod:`MongoDB\\Database::withOptions()`
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Client::__get()`
......@@ -25,9 +25,10 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-get-param.rst
:returns:
Return Values
-------------
A :phpclass:`MongoDB\\Collection` object.
A :phpclass:`MongoDB\\Collection` object.
Behavior
--------
......@@ -60,8 +61,9 @@ collections from the ``demo`` database:
$users = $db->users;
$systemProfile = $db->{'system.profile'};
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual
========================================
MongoDB\\DeleteResult::getDeletedCount()
========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\DeleteResult::getDeletedCount()
Return the number of documents that were deleted.
.. code-block:: php
function getDeletedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The number of documents that were deleted.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getDeletedCount()
<manual/en/mongodb-driver-writeresult.getdeletedcount.php>`
=======================================
MongoDB\\DeleteResult::isAcknowledged()
=======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\DeleteResult::isAcknowledged()
Return whether the write was acknowledged.
.. code-block:: php
function isAcknowledged(): boolean
Return Values
-------------
A boolean indicating whether the write was acknowledged.
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::isAcknowledged()
<manual/en/mongodb-driver-writeresult.isacknowledged.php>`
- :manual:`Write Concern </reference/write-concern>` in the MongoDB manual
......@@ -28,8 +28,9 @@ Definition
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
......@@ -32,8 +32,9 @@ Definition
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
......@@ -29,12 +29,14 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-find-option.rst
:returns:
Return Values
-------------
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Collection::find()`
- :phpmethod:`MongoDB\\Collection::find()`
......@@ -21,8 +21,9 @@ Definition
function getBucketName(): string
:returns:
Return Values
-------------
The name of this bucket as a string.
The name of this bucket as a string.
.. todo: add examples
......@@ -21,8 +21,9 @@ Definition
function getDatabaseName(): string
:returns:
Return Values
-------------
The name of the database containing this bucket as a string.
The name of the database containing this bucket as a string.
.. todo: add examples
......@@ -25,12 +25,14 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-getFileDocumentForStream-param.rst
:returns:
Return Values
-------------
The metadata document associated with the GridFS stream.
The metadata document associated with the GridFS stream.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileIdForStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileIdForStream()`
......@@ -25,13 +25,15 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-getFileIdForStream-param.rst
:returns:
Return Values
-------------
The ``_id`` field of the metadata document associated with the GridFS
stream.
The ``_id`` field of the metadata document associated with the GridFS
stream.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileDocumentForStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileDocumentForStream()`
......@@ -25,14 +25,16 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openDownloadStream-param.rst
:returns:
Return Values
-------------
A readable stream resource.
A readable stream resource.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
......@@ -29,14 +29,16 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openDownloadStreamByName-option.rst
:returns:
Return Values
-------------
A readable stream resource.
A readable stream resource.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
......@@ -29,9 +29,10 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openUploadStream-option.rst
:returns:
Return Values
-------------
A writable stream resource.
A writable stream resource.
Behavior
--------
......@@ -41,6 +42,7 @@ metadata document will be created when the writable stream is closed.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::uploadFromStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::uploadFromStream()`
......@@ -29,15 +29,17 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-uploadFromStream-option.rst
:returns:
Return Values
-------------
The ``_id`` field of the metadata document associated with the newly
created GridFS file. If the ``_id`` option is not specified, a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object will
be used by default.
The ``_id`` field of the metadata document associated with the newly created
GridFS file. If the ``_id`` option is not specified, a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object will be used
by default.
.. todo: add examples
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\GridFS\\Bucket::openUploadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openUploadStream()`
......@@ -39,6 +39,7 @@ the Bucket inherits its options from that object.
.. todo: add an example
.. seealso::
See Also
--------
- :phpmethod:`MongoDB\\Database::selectGridFSBucket()`
- :phpmethod:`MongoDB\\Database::selectGridFSBucket()`
=============================================
MongoDB\\InsertManyResult::getInsertedCount()
=============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertManyResult::getInsertedCount()
Return the number of documents that were inserted.
.. code-block:: php
function getInsertedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The number of documents that were inserted.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getInsertedCount()
<manual/en/mongodb-driver-writeresult.getinsertedcount.php>`
===========================================
MongoDB\\InsertManyResult::getInsertedIds()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertManyResult::getInsertedIds()
Return a map of IDs (i.e. ``_id`` field values) for the inserted documents.
.. code-block:: php
function getInsertedIds(): array
Since IDs are created by the driver, this method may be called irrespective
of whether the write was acknowledged.
Return Values
-------------
A map of IDs (i.e. ``_id`` field values) for the inserted documents.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to inserting (i.e. the driver did
not generate an ID), the index will contain its ``_id`` field value. Any
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
<class.mongodb-bson-objectid>` instance.
===========================================
MongoDB\\InsertManyResult::isAcknowledged()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertManyResult::isAcknowledged()
Return whether the write was acknowledged.
.. code-block:: php
function isAcknowledged(): boolean
Return Values
-------------
A boolean indicating whether the write was acknowledged.
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::isAcknowledged()
<manual/en/mongodb-driver-writeresult.isacknowledged.php>`
- :manual:`Write Concern </reference/write-concern>` in the MongoDB manual
============================================
MongoDB\\InsertOneResult::getInsertedCount()
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertOneResult::getInsertedCount()
Return the number of documents that were inserted.
.. code-block:: php
function getInsertedCount(): integer
This method should only be called if the write was acknowledged.
Return Values
-------------
The number of documents that were inserted. This should be ``1`` for an
acknowledged insert operation.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::getInsertedCount()
<manual/en/mongodb-driver-writeresult.getinsertedcount.php>`
=========================================
MongoDB\\InsertOneResult::getInsertedId()
=========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertOneResult::getInsertedId()
Return the ID (i.e. ``_id`` field value) for the inserted document.
.. code-block:: php
function getInsertedId(): mixed
Since IDs are created by the driver, this method may be called irrespective
of whether the write was acknowledged.
Return Values
-------------
The ID (i.e. ``_id`` field value) of the inserted document.
If the document had an ID prior to inserting (i.e. the driver did not need to
generate an ID), this will contain its ``_id`` field value. Any driver-generated
ID will be a :php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>`
instance.
==========================================
MongoDB\\InsertOneResult::isAcknowledged()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\InsertOneResult::isAcknowledged()
Return whether the write was acknowledged.
.. code-block:: php
function isAcknowledged(): boolean
Return Values
-------------
A boolean indicating whether the write was acknowledged.
See Also
--------
- :php:`MongoDB\\Driver\\WriteResult::isAcknowledged()
<manual/en/mongodb-driver-writeresult.isacknowledged.php>`
- :manual:`Write Concern </reference/write-concern>` in the MongoDB manual
==============================================
MongoDB\\Model\\CollectionInfo::getCappedMax()
==============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getCappedMax()
Return the document limit for the capped collection. This correlates with the
``max`` option for :phpmethod:`MongoDB\\Database::createCollection()`.
.. code-block:: php
function getCappedMax(): integer|null
Return Values
-------------
The document limit for the capped collection. If the collection is not capped,
``null`` will be returned.
See Also
--------
- :phpmethod:`MongoDB\\Model\\CollectionInfo::getCappedSize()`
- :phpmethod:`MongoDB\\Model\\CollectionInfo::isCapped()`
- :phpmethod:`MongoDB\\Database::createCollection()`
- :manual:`Capped Collections </core/capped-collections>` in the MongoDB manual
- :manual:`listCollections </reference/command/listCollections>` command
reference in the MongoDB manual
===============================================
MongoDB\\Model\\CollectionInfo::getCappedSize()
===============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getCappedSize()
Return the size limit for the capped collection in bytes. This correlates
with the ``size`` option for
:phpmethod:`MongoDB\\Database::createCollection()`.
.. code-block:: php
function getCappedSize(): integer|null
Return Values
-------------
The size limit for the capped collection in bytes. If the collection is not
capped, ``null`` will be returned.
See Also
--------
- :phpmethod:`MongoDB\\Model\\CollectionInfo::getCappedMax()`
- :phpmethod:`MongoDB\\Model\\CollectionInfo::isCapped()`
- :phpmethod:`MongoDB\\Database::createCollection()`
- :manual:`Capped Collections </core/capped-collections>` in the MongoDB manual
- :manual:`listCollections </reference/command/listCollections>` command
reference in the MongoDB manual
=========================================
MongoDB\\Model\\CollectionInfo::getName()
=========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getName()
Return the collection name.
.. code-block:: php
function getName(): string
Return Values
-------------
The collection name.
See Also
--------
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :manual:`listCollections </reference/command/listCollections>` command
reference in the MongoDB manual
============================================
MongoDB\\Model\\CollectionInfo::getOptions()
============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getOptions()
Return the collection options. This correlates with the options for
:phpmethod:`MongoDB\\Database::createCollection()`, but may include
additional fields set by the server.
.. code-block:: php
function getOptions(): array
Return Values
-------------
The collection options.
See Also
--------
- :phpmethod:`MongoDB\\Database::createCollection()`
- :manual:`listCollections </reference/command/listCollections>` command
reference in the MongoDB manual
==========================================
MongoDB\\Model\\CollectionInfo::isCapped()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\CollectionInfo::isCapped()
Return whether the collection is a :manual:`capped collection
</core/capped-collections>`.
.. code-block:: php
function isCapped(): boolean
Return Values
-------------
A boolean indicating whether the collection is a capped collection.
See Also
--------
- :phpmethod:`MongoDB\\Model\\CollectionInfo::getCappedMax()`
- :phpmethod:`MongoDB\\Model\\CollectionInfo::getCappedSize()`
- :manual:`Capped Collections </core/capped-collections>` in the MongoDB manual
- :manual:`listCollections </reference/command/listCollections>` command
reference in the MongoDB manual
=======================================
MongoDB\\Model\\DatabaseInfo::getName()
=======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\DatabaseInfo::getName()
Return the database name.
.. code-block:: php
function getName(): string
Return Values
-------------
The database name.
See Also
--------
- :phpmethod:`MongoDB\\Database::getDatabaseName()`
- :manual:`listDatabases </reference/command/listDatabases>` command reference
in the MongoDB manual
=============================================
MongoDB\\Model\\DatabaseInfo::getSizeOnDisk()
=============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\DatabaseInfo::getSizeOnDisk()
Return the total size of the database file on disk in bytes.
.. code-block:: php
function getSizeOnDisk(): integer
Return Values
-------------
The total size of the database file on disk in bytes.
See Also
--------
- :manual:`listDatabases </reference/command/listDatabases>` command reference
in the MongoDB manual
=======================================
MongoDB\\Model\\DatabaseInfo::isEmpty()
=======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\DatabaseInfo::isEmpty()
Return whether the database has any data.
.. code-block:: php
function isEmpty(): boolean
Return Values
-------------
A boolean indicating whether the database has any data.
See Also
--------
- :manual:`listDatabases </reference/command/listDatabases>` command reference
in the MongoDB manual
===================================
MongoDB\\Model\\IndexInfo::getKey()
===================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\IndexInfo::getKey()
Return the index specification (i.e. indexed field(s) and order). This
correlates with the ``$key`` parameter for
:phpmethod:`MongoDB\\Collection::createIndex()`.
.. code-block:: php
function getKey(): array
Return Values
-------------
The index specification as an associative array.
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
====================================
MongoDB\\Model\\IndexInfo::getName()
====================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\IndexInfo::getName()
Return the index name. This correlates with the return value of
:phpmethod:`MongoDB\\Collection::createIndex()`. An index name may be derived
from the ``$key`` parameter or or explicitly specified via the ``name``
option.
.. code-block:: php
function getName(): string
Return Values
-------------
The index name.
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
=========================================
MongoDB\\Model\\IndexInfo::getNamespace()
=========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\IndexInfo::getNamespace()
Return the index namespace, which is the namespace of the collection
containing the index.
.. code-block:: php
function getNamespace(): string
Return Values
-------------
The index namespace.
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
=======================================
MongoDB\\Model\\IndexInfo::getVersion()
=======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Model\\IndexInfo::getVersion()
Return the index version.
.. code-block:: php
function getVersion(): integer
Return Values
-------------
The index version.
See Also
--------
- :phpmethod:`MongoDB\\Collection::createIndex()`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
the MongoDB manual
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment