Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401]
(no description)
File Size: | 1134 lines (46 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Collection:: (39 methods):
__construct()
__debugInfo()
__toString()
aggregate()
bulkWrite()
count()
countDocuments()
createIndex()
createIndexes()
deleteMany()
deleteOne()
distinct()
drop()
dropIndex()
dropIndexes()
estimatedDocumentCount()
explain()
find()
findOne()
findOneAndDelete()
findOneAndReplace()
findOneAndUpdate()
getCollectionName()
getDatabaseName()
getManager()
getNamespace()
getReadConcern()
getReadPreference()
getTypeMap()
getWriteConcern()
insertMany()
insertOne()
listIndexes()
mapReduce()
replaceOne()
updateMany()
updateOne()
watch()
withOptions()
Class: Collection - X-Ref
__construct(Manager $manager, $databaseName, $collectionName, array $options = []) X-Ref |
Constructs new Collection instance. This class provides methods for collection-specific operations, such as CRUD (i.e. create, read, update, and delete) and index management. Supported options: * readConcern (MongoDB\Driver\ReadConcern): The default read concern to use for collection operations. Defaults to the Manager's read concern. * readPreference (MongoDB\Driver\ReadPreference): The default read preference to use for collection operations. Defaults to the Manager's read preference. * typeMap (array): Default type map for cursors and BSON documents. * writeConcern (MongoDB\Driver\WriteConcern): The default write concern to use for collection operations. Defaults to the Manager's write concern. param: Manager $manager Manager instance from the driver param: string $databaseName Database name param: string $collectionName Collection name param: array $options Collection options |
__debugInfo() X-Ref |
Return internal properties for debugging purposes. return: array |
__toString() X-Ref |
Return the collection namespace (e.g. "db.collection"). return: string |
aggregate(array $pipeline, array $options = []) X-Ref |
Executes an aggregation framework pipeline on the collection. Note: this method's return value depends on the MongoDB server version and the "useCursor" option. If "useCursor" is true, a Cursor will be returned; otherwise, an ArrayIterator is returned, which wraps the "result" array from the command response document. return: Traversable param: array $pipeline List of pipeline operations param: array $options Command options |
bulkWrite(array $operations, array $options = []) X-Ref |
Executes multiple write operations. return: BulkWriteResult param: array[] $operations List of write operations param: array $options Command options |
count($filter = [], array $options = []) X-Ref |
Gets the number of documents matching the filter. return: integer param: array|object $filter Query by which to filter documents param: array $options Command options |
countDocuments($filter = [], array $options = []) X-Ref |
Gets the number of documents matching the filter. return: integer param: array|object $filter Query by which to filter documents param: array $options Command options |
createIndex($key, array $options = []) X-Ref |
Create a single index for the collection. return: string The name of the created index param: array|object $key Document containing fields mapped to values, param: array $options Index and command options |
createIndexes(array $indexes, array $options = []) X-Ref |
Create one or more indexes for the collection. Each element in the $indexes array must have a "key" document, which contains fields mapped to an order or type. Other options may follow. For example: $indexes = [ // Create a unique index on the "username" field [ 'key' => [ 'username' => 1 ], 'unique' => true ], // Create a 2dsphere index on the "loc" field with a custom name [ 'key' => [ 'loc' => '2dsphere' ], 'name' => 'geo' ], ]; If the "name" option is unspecified, a name will be generated from the "key" document. return: string[] The names of the created indexes param: array[] $indexes List of index specifications param: array $options Command options |
deleteMany($filter, array $options = []) X-Ref |
Deletes all documents matching the filter. return: DeleteResult param: array|object $filter Query by which to delete documents param: array $options Command options |
deleteOne($filter, array $options = []) X-Ref |
Deletes at most one document matching the filter. return: DeleteResult param: array|object $filter Query by which to delete documents param: array $options Command options |
distinct($fieldName, $filter = [], array $options = []) X-Ref |
Finds the distinct values for a specified field across the collection. return: mixed[] param: string $fieldName Field for which to return distinct values param: array|object $filter Query by which to filter documents param: array $options Command options |
drop(array $options = []) X-Ref |
Drop this collection. return: array|object Command result document param: array $options Additional options |
dropIndex($indexName, array $options = []) X-Ref |
Drop a single index in the collection. return: array|object Command result document param: string|IndexInfo $indexName Index name or model object param: array $options Additional options |
dropIndexes(array $options = []) X-Ref |
Drop all indexes in the collection. return: array|object Command result document param: array $options Additional options |
estimatedDocumentCount(array $options = []) X-Ref |
Gets an estimated number of documents in the collection using the collection metadata. return: integer param: array $options Command options |
explain(Explainable $explainable, array $options = []) X-Ref |
Explains explainable commands. return: array|object param: Explainable $explainable Command on which to run explain param: array $options Additional options |
find($filter = [], array $options = []) X-Ref |
Finds documents matching the query. return: Cursor param: array|object $filter Query by which to filter documents param: array $options Additional options |
findOne($filter = [], array $options = []) X-Ref |
Finds a single document matching the query. return: array|object|null param: array|object $filter Query by which to filter documents param: array $options Additional options |
findOneAndDelete($filter, array $options = []) X-Ref |
Finds a single document and deletes it, returning the original. The document to return may be null if no document matched the filter. return: array|object|null param: array|object $filter Query by which to filter documents param: array $options Command options |
findOneAndReplace($filter, $replacement, array $options = []) X-Ref |
Finds a single document and replaces it, returning either the original or the replaced document. The document to return may be null if no document matched the filter. By default, the original document is returned. Specify FindOneAndReplace::RETURN_DOCUMENT_AFTER for the "returnDocument" option to return the updated document. return: array|object|null param: array|object $filter Query by which to filter documents param: array|object $replacement Replacement document param: array $options Command options |
findOneAndUpdate($filter, $update, array $options = []) X-Ref |
Finds a single document and updates it, returning either the original or the updated document. The document to return may be null if no document matched the filter. By default, the original document is returned. Specify FindOneAndUpdate::RETURN_DOCUMENT_AFTER for the "returnDocument" option to return the updated document. return: array|object|null param: array|object $filter Query by which to filter documents param: array|object $update Update to apply to the matched document param: array $options Command options |
getCollectionName() X-Ref |
Return the collection name. return: string |
getDatabaseName() X-Ref |
Return the database name. return: string |
getManager() X-Ref |
Return the Manager. return: Manager |
getNamespace() X-Ref |
Return the collection namespace. return: string |
getReadConcern() X-Ref |
Return the read concern for this collection. return: ReadConcern |
getReadPreference() X-Ref |
Return the read preference for this collection. return: ReadPreference |
getTypeMap() X-Ref |
Return the type map for this collection. return: array |
getWriteConcern() X-Ref |
Return the write concern for this collection. return: WriteConcern |
insertMany(array $documents, array $options = []) X-Ref |
Inserts multiple documents. return: InsertManyResult param: array[]|object[] $documents The documents to insert param: array $options Command options |
insertOne($document, array $options = []) X-Ref |
Inserts one document. return: InsertOneResult param: array|object $document The document to insert param: array $options Command options |
listIndexes(array $options = []) X-Ref |
Returns information for all indexes for the collection. return: IndexInfoIterator param: array $options |
mapReduce(JavascriptInterface $map, JavascriptInterface $reduce, $out, array $options = []) X-Ref |
Executes a map-reduce aggregation on the collection. return: MapReduceResult param: JavascriptInterface $map Map function param: JavascriptInterface $reduce Reduce function param: string|array|object $out Output specification param: array $options Command options |
replaceOne($filter, $replacement, array $options = []) X-Ref |
Replaces at most one document matching the filter. return: UpdateResult param: array|object $filter Query by which to filter documents param: array|object $replacement Replacement document param: array $options Command options |
updateMany($filter, $update, array $options = []) X-Ref |
Updates all documents matching the filter. return: UpdateResult param: array|object $filter Query by which to filter documents param: array|object $update Update to apply to the matched documents param: array $options Command options |
updateOne($filter, $update, array $options = []) X-Ref |
Updates at most one document matching the filter. return: UpdateResult param: array|object $filter Query by which to filter documents param: array|object $update Update to apply to the matched document param: array $options Command options |
watch(array $pipeline = [], array $options = []) X-Ref |
Create a change stream for watching changes to the collection. return: ChangeStream param: array $pipeline List of pipeline operations param: array $options Command options |
withOptions(array $options = []) X-Ref |
Get a clone of this collection with different options. return: Collection param: array $options Collection constructor options |