Definition
- MongoDB\Collection::__construct()
- Constructs a new - Collectioninstance.- function __construct( - MongoDB\Driver\Manager $manager, - string $databaseName, - string $collectionName, - array $options = [] - ) - This constructor has the following parameters: 
- $manager: MongoDB\Driver\Manager
- The Manager instance from the driver. The manager maintains connections between the driver and your MongoDB instances.
- $databaseName: string
- The name of the database.
- $collectionName: string
- The name of the collection.
- $options: array
- An array specifying the desired options. NameTypeDescription- builderEncoder - MongoDB\Codec\Encoder - Encoder to use for query and aggregation builders. If not set, this option defaults to a new instance of the - MongoDB\Builder\BuilderEncoderclass.- New in version 1.21. - codec - MongoDB\Codec\DocumentCodec - The default Encode Data with Type Codecs to use for collection operations. - New in version 1.17. - readConcern - The default read concern to use for collection operations. Defaults to the manager's read concern. - readPreference - The default read preference to use for collection operations. Defaults to the manager's read preference. - typeMap - array - Default type map to apply to cursors, which determines how BSON documents are converted to PHP values. The library uses the following type map by default: - [ - 'array' => 'MongoDB\Model\BSONArray', - 'document' => 'MongoDB\Model\BSONDocument', - 'root' => 'MongoDB\Model\BSONDocument', - ] - writeConcern - The default write concern to use for collection operations. Defaults to the manager's write concern. 
Errors/Exceptions
MongoDB\Exception\InvalidArgumentException for errors related to
the parsing of parameters or options.
Behavior
If you construct a Collection explicitly, the Collection inherits any options
from the MongoDB\Driver\Manager object.
If you select the Collection from a Client or
Database object, the Collection inherits its
options from that object.