PHP Класс Phalcon\Db\Adapter\MongoDB\Collection

Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( MongoDB\Driver\Manager $manager, string $databaseName, string $collectionName, array $options = [] ) Constructs new Collection instance.
__debugInfo ( ) : array Return internal properties for debugging purposes.
__toString ( ) : string Return the collection namespace (e.g. "db.collection").
aggregate ( array $pipeline, array $options = [] ) : Traversable Executes an aggregation framework pipeline on the collection.
bulkWrite ( array $operations, array $options = [] ) : BulkWriteResult Executes multiple write operations.
count ( array | object $filter = [], array $options = [] ) : integer Gets the number of documents matching the filter.
createIndex ( array | object $key, array $options = [] ) : string Create a single index for the collection.
createIndexes ( array $indexes ) : string[] Create one or more indexes for the collection.
deleteMany ( array | object $filter, array $options = [] ) : DeleteResult Deletes all documents matching the filter.
deleteOne ( array | object $filter, array $options = [] ) : DeleteResult Deletes at most one document matching the filter.
distinct ( string $fieldName, array | object $filter = [], array $options = [] ) : mixed[] Finds the distinct values for a specified field across the collection.
drop ( array $options = [] ) : array | object Drop this collection.
dropIndex ( string $indexName, array $options = [] ) : array | object Drop a single index in the collection.
dropIndexes ( array $options = [] ) : array | object Drop all indexes in the collection.
find ( array | object $filter = [], array $options = [] ) : MongoDB\Driver\Cursor Finds documents matching the query.
findOne ( array | object $filter = [], array $options = [] ) : array | object | null Finds a single document matching the query.
findOneAndDelete ( array | object $filter, array $options = [] ) : object | null Finds a single document and deletes it, returning the original.
findOneAndReplace ( array | object $filter, array | object $replacement, array $options = [] ) : object | null Finds a single document and replaces it, returning either the original or the replaced document.
findOneAndUpdate ( array | object $filter, array | object $update, array $options = [] ) : object | null Finds a single document and updates it, returning either the original or the updated document.
getCollectionName ( ) : string Return the collection name.
getDatabaseName ( ) : string Return the database name.
getNamespace ( ) : string Return the collection namespace.
insertMany ( array $documents, array $options = [] ) : InsertManyResult Inserts multiple documents.
insertOne ( array | object $document, array $options = [] ) : InsertOneResult Inserts one document.
listIndexes ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\IndexInfoIterator Returns information for all indexes for the collection.
replaceOne ( array | object $filter, array | object $replacement, array $options = [] ) : UpdateResult Replaces at most one document matching the filter.
updateMany ( array | object $filter, array | object $update, array $options = [] ) : UpdateResult Updates all documents matching the filter.
updateOne ( array | object $filter, array | object $update, array $options = [] ) : UpdateResult Updates at most one document matching the filter.
withOptions ( array $options = [] ) : Collection Get a clone of this collection with different options.

Описание методов

__construct() публичный метод

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.
public __construct ( MongoDB\Driver\Manager $manager, string $databaseName, string $collectionName, array $options = [] )
$manager MongoDB\Driver\Manager Manager instance from the driver
$databaseName string Database name
$collectionName string Collection name
$options array Collection options

__debugInfo() публичный метод

Return internal properties for debugging purposes.
См. также: http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
public __debugInfo ( ) : array
Результат array

__toString() публичный метод

Return the collection namespace (e.g. "db.collection").
См. также: https://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace
public __toString ( ) : string
Результат string

aggregate() публичный метод

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. Note: BSON deserialization of inline aggregation results (i.e. not using a command cursor) does not yet support a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
См. также: Aggregate::__construct() for supported options
public aggregate ( array $pipeline, array $options = [] ) : Traversable
$pipeline array List of pipeline operations
$options array Command options
Результат Traversable

bulkWrite() публичный метод

Executes multiple write operations.
См. также: BulkWrite::__construct() for supported options
public bulkWrite ( array $operations, array $options = [] ) : BulkWriteResult
$operations array List of write operations
$options array Command options
Результат BulkWriteResult

count() публичный метод

Gets the number of documents matching the filter.
См. также: Count::__construct() for supported options
public count ( array | object $filter = [], array $options = [] ) : integer
$filter array | object Query by which to filter documents
$options array Command options
Результат integer

createIndex() публичный метод

Create a single index for the collection.
См. также: Collection::createIndexes()
public createIndex ( array | object $key, array $options = [] ) : string
$key array | object Document containing fields mapped to values, which denote order or an index type
$options array Index options
Результат string The name of the created index

createIndexes() публичный метод

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.
См. также: http://docs.mongodb.org/manual/reference/command/createIndexes/
См. также: http://docs.mongodb.org/manual/reference/method/db.collection.createIndex/
public createIndexes ( array $indexes ) : string[]
$indexes array List of index specifications
Результат string[] The names of the created indexes

deleteMany() публичный метод

Deletes all documents matching the filter.
См. также: DeleteMany::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/delete/
public deleteMany ( array | object $filter, array $options = [] ) : DeleteResult
$filter array | object Query by which to delete documents
$options array Command options
Результат DeleteResult

deleteOne() публичный метод

Deletes at most one document matching the filter.
См. также: DeleteOne::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/delete/
public deleteOne ( array | object $filter, array $options = [] ) : DeleteResult
$filter array | object Query by which to delete documents
$options array Command options
Результат DeleteResult

distinct() публичный метод

Finds the distinct values for a specified field across the collection.
См. также: Distinct::__construct() for supported options
public distinct ( string $fieldName, array | object $filter = [], array $options = [] ) : mixed[]
$fieldName string Field for which to return distinct values
$filter array | object Query by which to filter documents
$options array Command options
Результат mixed[]

drop() публичный метод

Drop this collection.
См. также: DropCollection::__construct() for supported options
public drop ( array $options = [] ) : array | object
$options array Additional options
Результат array | object Command result document

dropIndex() публичный метод

Drop a single index in the collection.
См. также: DropIndexes::__construct() for supported options
public dropIndex ( string $indexName, array $options = [] ) : array | object
$indexName string Index name
$options array Additional options
Результат array | object Command result document

dropIndexes() публичный метод

Drop all indexes in the collection.
См. также: DropIndexes::__construct() for supported options
public dropIndexes ( array $options = [] ) : array | object
$options array Additional options
Результат array | object Command result document

find() публичный метод

Finds documents matching the query.
См. также: Find::__construct() for supported options
См. также: http://docs.mongodb.org/manual/core/read-operations-introduction/
public find ( array | object $filter = [], array $options = [] ) : MongoDB\Driver\Cursor
$filter array | object Query by which to filter documents
$options array Additional options
Результат MongoDB\Driver\Cursor

findOne() публичный метод

Finds a single document matching the query.
См. также: FindOne::__construct() for supported options
См. также: http://docs.mongodb.org/manual/core/read-operations-introduction/
public findOne ( array | object $filter = [], array $options = [] ) : array | object | null
$filter array | object Query by which to filter documents
$options array Additional options
Результат array | object | null

findOneAndDelete() публичный метод

The document to return may be null if no document matched the filter. Note: BSON deserialization of the returned document does not yet support a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
См. также: FindOneAndDelete::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/findAndModify/
public findOneAndDelete ( array | object $filter, array $options = [] ) : object | null
$filter array | object Query by which to filter documents
$options array Command options
Результат object | null

findOneAndReplace() публичный метод

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. Note: BSON deserialization of the returned document does not yet support a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
См. также: FindOneAndReplace::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/findAndModify/
public findOneAndReplace ( array | object $filter, array | object $replacement, array $options = [] ) : object | null
$filter array | object Query by which to filter documents
$replacement array | object Replacement document
$options array Command options
Результат object | null

findOneAndUpdate() публичный метод

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. Note: BSON deserialization of the returned document does not yet support a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
См. также: FindOneAndReplace::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/findAndModify/
public findOneAndUpdate ( array | object $filter, array | object $update, array $options = [] ) : object | null
$filter array | object Query by which to filter documents
$update array | object Update to apply to the matched document
$options array Command options
Результат object | null

getCollectionName() публичный метод

Return the collection name.
public getCollectionName ( ) : string
Результат string

getDatabaseName() публичный метод

Return the database name.
public getDatabaseName ( ) : string
Результат string

getNamespace() публичный метод

Return the collection namespace.
См. также: https://docs.mongodb.org/manual/reference/glossary/#term-namespace
public getNamespace ( ) : string
Результат string

insertMany() публичный метод

Inserts multiple documents.
См. также: InsertMany::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/insert/
public insertMany ( array $documents, array $options = [] ) : InsertManyResult
$documents array The documents to insert
$options array Command options
Результат InsertManyResult

insertOne() публичный метод

Inserts one document.
См. также: InsertOne::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/insert/
public insertOne ( array | object $document, array $options = [] ) : InsertOneResult
$document array | object The document to insert
$options array Command options
Результат InsertOneResult

listIndexes() публичный метод

Returns information for all indexes for the collection.
См. также: ListIndexes::__construct() for supported options
public listIndexes ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\IndexInfoIterator
$options array
Результат Phalcon\Db\Adapter\MongoDB\Model\IndexInfoIterator

replaceOne() публичный метод

Replaces at most one document matching the filter.
См. также: ReplaceOne::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/update/
public replaceOne ( array | object $filter, array | object $replacement, array $options = [] ) : UpdateResult
$filter array | object Query by which to filter documents
$replacement array | object Replacement document
$options array Command options
Результат UpdateResult

updateMany() публичный метод

Updates all documents matching the filter.
См. также: UpdateMany::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/update/
public updateMany ( array | object $filter, array | object $update, array $options = [] ) : UpdateResult
$filter array | object Query by which to filter documents
$update array | object Update to apply to the matched documents
$options array Command options
Результат UpdateResult

updateOne() публичный метод

Updates at most one document matching the filter.
См. также: UpdateOne::__construct() for supported options
См. также: http://docs.mongodb.org/manual/reference/command/update/
public updateOne ( array | object $filter, array | object $update, array $options = [] ) : UpdateResult
$filter array | object Query by which to filter documents
$update array | object Update to apply to the matched document
$options array Command options
Результат UpdateResult

withOptions() публичный метод

Get a clone of this collection with different options.
См. также: Collection::__construct() for supported options
public withOptions ( array $options = [] ) : Collection
$options array Collection constructor options
Результат Collection