You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
MongoDB\Collection Class
Definition
MongoDB\CollectionProvides methods for common operations on collections and documents, including CRUD operations and index management.
You can construct collections directly using the extension's MongoDB\Driver\Manager class or select a collection from the library's
MongoDB\ClientorMongoDB\Databaseclasses. A collection may also be cloned from an existingMongoDB\Collectionobject via thewithOptions()method.MongoDB\Collectionsupports the readConcern, readPreference, typeMap, and writeConcern options. If you omit an option, the collection inherits the value from the Manager constructor argument or theClientorDatabaseobject used to select the collection.Operations within the
MongoDB\Collectionclass inherit the collection's options.