PHP 클래스 Sokil\Mongo\Collection

It aggregates \MongoCollection instance.
저자: Dmytro Sokil ([email protected])
상속: implements Countable
파일 보기 프로젝트 열기: sokil/php-mongo 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_index Every index definition must contain key 'keys' with list of fields and orders, and optional options from @link http://php.net/manual/en/mongocollection.createindex.php: Example: array( array( 'keys' => array('field1' => 1, 'field2' => -1), 'unique' => true ), ... )
$_queryExpressionClass expression class. This class may be overloaded to define own query methods (whereUserAgeGreatedThan(), etc.)
$mongoCollectionClassName
$versioning default value of versioning

공개 메소드들

메소드 설명
__construct ( Database $database, $collection, Definition $definition = null )
__get ( $name )
addDocumentToDocumentPool ( Document $document ) : Collection Store document to pool
addDocumentsToDocumentPool ( array $documents ) : Collection Store documents to identity map
aggregate ( callable | array | Pipeline $pipeline, array $options = [], boolean $asCursor = false ) : array Aggregate using pipeline
batchDelete ( callable | array | Expression $expression = [] ) : Collection Delete documents by expression
batchInsert ( array $rows, $validate = true ) : Collection Insert multiple documents defined as arrays
batchUpdate ( Expression | array | callable $expression, Operator | array | callable $updateData ) : Collection Update multiple documents
clearDocumentPool ( )
count ( ) : integer Total count of documents in collection
createAggregator ( ) : Pipeline Start aggregation
createBatchDelete ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchDelete Creates batch delete operation handler
createBatchInsert ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchInsert Creates batch insert operation handler
createBatchUpdate ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchUpdate Creates batch update operation handler
createDocument ( array $data = null ) : Document Factory method to get not stored Document instance from array
createIndex ( array $key, array $options = [] ) : Collection Create index
delete ( ) : Collection Delete collection
deleteDocument ( Document $document ) : Collection
deleteDocuments ( $expression = [] )
deleteIndex ( array $key ) : Collection Delete index
disableDocumentPool ( ) : Collection Stop storing found documents to pool
documentPoolCount ( ) : integer Get number of documents in document pool
enableDocumentPool ( ) : Collection Start storing found documents to pool
enableVersioning ( ) : Collection Start versioning documents on modify
ensure2dIndex ( string $field ) : Collection Create geo index 2dsphere
ensure2dSphereIndex ( string $field ) : Collection Create geo index 2dsphere
ensureFulltextIndex ( array | string $field = '$**', array $weights = null, $defaultLanguage = Language::ENGLISH, $languageOverride = null ) : Collection Create fulltext index
ensureIndex ( array $key, array $options = [] ) : Collection Create index
ensureSparseIndex ( array $key ) : Collection Create sparse index.
ensureTTLIndex ( array $key, integer $seconds ) : Collection Create TTL index
ensureUniqueIndex ( array $key, boolean $dropDups = false ) : Collection Create unique index
explainAggregate ( array | Pipeline $pipeline ) : array Explain aggregation
expression ( ) : Expression Create new Expression instance to use in query builder or update operations
find ( $callable = null ) : Cursor | Expression Create document query builder
findAsArray ( $callable = null ) : Cursor Create document query builder
getDatabase ( ) : Database
getDistinct ( string $selector, array | callable | Expression $expression = null ) : array Retrieve a list of distinct values for the given key across a collection.
getDocument ( string | MongoId $id, callable $callable = null ) : Document | array | null Get document by id If callable specified, document always loaded directly omitting document pool.
getDocumentByReference ( array $ref, boolean $useDocumentPool = true ) : Document | null Get Document instance by it's reference
getDocumentClassName ( array $documentData = null ) : string Override to define class name of document by document data
getDocumentDirectly ( string | MongoId $id, callable $callable = null ) : Document | array | null Get document by id directly omitting cache Method may return document as array if cursor configured through Cursor::asArray()
getDocumentFromDocumentPool ( string | integer | MongoId $id ) : Document Get document from identity map by it's id
getDocuments ( array $idList, callable $callable = null ) : array | null Get documents by list of id
getDocumentsFromDocumentPool ( array $ids = null ) Get documents from pool if they stored
getIndexes ( ) : array Get index info
getMongoCollection ( ) : MongoCollection Get native collection instance of mongo driver
getName ( ) : string Get name of collection
getOption ( string | integer $name ) : mixed Get option
getOptions ( )
getReadPreference ( )
getWriteConcern ( ) : integer | string Get currently active write concern on all requests to collection
hasDocument ( Document $document ) : type Check if document belongs to collection
hydrate ( array $data, $useDocumentPool = true ) : Document Factory method to get document object from array of stored document
initIndexes ( ) : Collection Create indexes based on self::$_index metadata
insert ( array $document ) : Collection Direct insert of array to MongoDB without creating document object and validation
insertMultiple ( $rows, $validate = true )
isDocumentInDocumentPool ( Document | MongoId | integer | string $document ) : boolean Check if document exists in identity map
isDocumentPoolEmpty ( ) : boolean Check if documents are in pool
isDocumentPoolEnabled ( ) : boolean Check if document pool enabled and requested documents store to it
isVersioningEnabled ( ) : boolean Check if versioning enabled
operator ( ) : Operator Create Operator instance to use in update operations
readNearest ( array $tags = null )
readPrimaryOnly ( )
readPrimaryPreferred ( array $tags = null )
readSecondaryOnly ( array $tags = null )
readSecondaryPreferred ( array $tags = null )
removeDocumentFromDocumentPool ( Document $document ) : Collection Remove document instance from identity map
setMajorityWriteConcern ( integer $timeout = 10000 ) : Collection Define majority write concern for all requests to current collection
setUnacknowledgedWriteConcern ( integer $timeout = 10000 ) : Collection Define unacknowledged write concern for all requests to current collection
setWriteConcern ( string | integer $w, integer $timeout = 10000 ) : Collection Define write concern for all requests to current collection
stats ( ) : array Get collection stat
update ( Expression | array | callable $expression, Operator | array | callable $updateData, array $options = [] ) : Collection Update multiple documents
updateAll ( Operator | array | callable $updateData ) : Collection Update all documents
updateMultiple ( $expression, $updateData )
validate ( boolean $full = false ) : array Validates a collection. The method scans a collection’s data structures for correctness and returns a single document that describes the relationship between the logical collection and the physical representation of the data.

메소드 상세

__construct() 공개 메소드

public __construct ( Database $database, $collection, Definition $definition = null )
$database Database
$definition Sokil\Mongo\Collection\Definition

__get() 공개 메소드

public __get ( $name )

addDocumentToDocumentPool() 공개 메소드

Store document to pool
public addDocumentToDocumentPool ( Document $document ) : Collection
$document Document
리턴 Collection

addDocumentsToDocumentPool() 공개 메소드

Store documents to identity map
public addDocumentsToDocumentPool ( array $documents ) : Collection
$documents array list of Document instances
리턴 Collection

aggregate() 공개 메소드

Aggregate using pipeline
public aggregate ( callable | array | Pipeline $pipeline, array $options = [], boolean $asCursor = false ) : array
$pipeline callable | array | Pipeline list of pipeline stages
$options array
$asCursor boolean return result as cursor
리턴 array result of aggregation

batchDelete() 공개 메소드

Delete documents by expression
public batchDelete ( callable | array | Expression $expression = [] ) : Collection
$expression callable | array | Expression
리턴 Collection

batchInsert() 공개 메소드

Prior to version 1.5.0 of the driver it was possible to use MongoCollection::batchInsert(), however, as of 1.5.0 that method is now discouraged. You can use Collection::createBatchInsert()
public batchInsert ( array $rows, $validate = true ) : Collection
$rows array list of documents to insert, defined as arrays
리턴 Collection

batchUpdate() 공개 메소드

Update multiple documents
public batchUpdate ( Expression | array | callable $expression, Operator | array | callable $updateData ) : Collection
$expression Expression | array | callable expression to define which documents will change.
$updateData Operator | array | callable new data or operators to update
리턴 Collection

clearDocumentPool() 공개 메소드

public clearDocumentPool ( )

count() 공개 메소드

Total count of documents in collection
public count ( ) : integer
리턴 integer

createAggregator() 공개 메소드

Start aggregation
public createAggregator ( ) : Pipeline
리턴 Pipeline

createBatchDelete() 공개 메소드

Creates batch delete operation handler
public createBatchDelete ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchDelete
$writeConcern integer | string Write concern. Default is 1 (Acknowledged)
$timeout integer Timeout for write concern. Default is 10000 milliseconds
$ordered boolean Determins if MongoDB must apply this batch in order (sequentally, one item at a time) or can rearrange it. Defaults to TRUE
리턴 Sokil\Mongo\BatchDelete

createBatchInsert() 공개 메소드

Creates batch insert operation handler
public createBatchInsert ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchInsert
$writeConcern integer | string Write concern. Default is 1 (Acknowledged)
$timeout integer Timeout for write concern. Default is 10000 milliseconds
$ordered boolean Determins if MongoDB must apply this batch in order (sequentally, one item at a time) or can rearrange it. Defaults to TRUE
리턴 Sokil\Mongo\BatchInsert

createBatchUpdate() 공개 메소드

Creates batch update operation handler
public createBatchUpdate ( integer | string $writeConcern = null, integer $timeout = null, boolean $ordered = null ) : Sokil\Mongo\BatchUpdate
$writeConcern integer | string Write concern. Default is 1 (Acknowledged)
$timeout integer Timeout for write concern. Default is 10000 milliseconds
$ordered boolean Determins if MongoDB must apply this batch in order (sequentally, one item at a time) or can rearrange it. Defaults to TRUE
리턴 Sokil\Mongo\BatchUpdate

createDocument() 공개 메소드

Factory method to get not stored Document instance from array
public createDocument ( array $data = null ) : Document
$data array
리턴 Document

createIndex() 공개 메소드

Create index
public createIndex ( array $key, array $options = [] ) : Collection
$key array
$options array see @link http://php.net/manual/en/mongocollection.ensureindex.php
리턴 Collection

delete() 공개 메소드

Delete collection
public delete ( ) : Collection
리턴 Collection

deleteDocument() 공개 메소드

사용 중단: since 1.13. Use Document::delete()
public deleteDocument ( Document $document ) : Collection
$document Document
리턴 Collection

deleteDocuments() 공개 메소드

사용 중단: since 1.13. Use Collection::batchDelete();
public deleteDocuments ( $expression = [] )

deleteIndex() 공개 메소드

Delete index
public deleteIndex ( array $key ) : Collection
$key array
리턴 Collection

disableDocumentPool() 공개 메소드

Stop storing found documents to pool
public disableDocumentPool ( ) : Collection
리턴 Collection

documentPoolCount() 공개 메소드

Get number of documents in document pool
public documentPoolCount ( ) : integer
리턴 integer

enableDocumentPool() 공개 메소드

Start storing found documents to pool
public enableDocumentPool ( ) : Collection
리턴 Collection

enableVersioning() 공개 메소드

Start versioning documents on modify
사용 중단: since 1.13 Use 'versioning' declaration in mapping
public enableVersioning ( ) : Collection
리턴 Collection

ensure2dIndex() 공개 메소드

Create geo index 2dsphere
public ensure2dIndex ( string $field ) : Collection
$field string
리턴 Collection

ensure2dSphereIndex() 공개 메소드

Create geo index 2dsphere
public ensure2dSphereIndex ( string $field ) : Collection
$field string
리턴 Collection

ensureFulltextIndex() 공개 메소드

Create fulltext index
public ensureFulltextIndex ( array | string $field = '$**', array $weights = null, $defaultLanguage = Language::ENGLISH, $languageOverride = null ) : Collection
$field array | string definition of fields where full text index ensured. May be string to ensure index on one field, array of fields to create full text index on few fields, and widdcard '$**' to create index on all fields of collection. Default value is '$**'
$weights array For a text index, the weight of an indexed field denotes the significance of the field relative to the other indexed fields in terms of the text search score.
$defaultLanguage The default language associated with the indexed data determines the rules to parse word roots (i.e. stemming) and ignore stop words. The default language for the indexed data is english.
$languageOverride To use a field with a name other than language, include the language_override option when creating the index.
리턴 Collection

ensureIndex() 공개 메소드

Create index
사용 중단: since 1.19 Use self::createIndex()
public ensureIndex ( array $key, array $options = [] ) : Collection
$key array
$options array see @link http://php.net/manual/en/mongocollection.ensureindex.php
리턴 Collection

ensureSparseIndex() 공개 메소드

Sparse indexes only contain entries for documents that have the indexed field, even if the index field contains a null value. The index skips over any document that is missing the indexed field.
public ensureSparseIndex ( array $key ) : Collection
$key array An array specifying the index's fields as its keys. For each field, the value is either the index direction or index type. If specifying direction, specify 1 for ascending or -1 for descending.
리턴 Collection

ensureTTLIndex() 공개 메소드

Create TTL index
public ensureTTLIndex ( array $key, integer $seconds ) : Collection
$key array key must be date to use TTL
$seconds integer
리턴 Collection

ensureUniqueIndex() 공개 메소드

Create unique index
public ensureUniqueIndex ( array $key, boolean $dropDups = false ) : Collection
$key array
$dropDups boolean
리턴 Collection

explainAggregate() 공개 메소드

Explain aggregation
사용 중단: use pipeline option 'explain' in Collection::aggregate() or method Pipeline::explain()
public explainAggregate ( array | Pipeline $pipeline ) : array
$pipeline array | Pipeline
리턴 array result

expression() 공개 메소드

Create new Expression instance to use in query builder or update operations
public expression ( ) : Expression
리턴 Expression

find() 공개 메소드

Create document query builder
public find ( $callable = null ) : Cursor | Expression
$callable callable|null Function to configure query builder&
리턴 Cursor | Expression

findAsArray() 공개 메소드

Create document query builder
public findAsArray ( $callable = null ) : Cursor
리턴 Cursor

getDatabase() 공개 메소드

public getDatabase ( ) : Database
리턴 Database

getDistinct() 공개 메소드

Retrieve a list of distinct values for the given key across a collection.
public getDistinct ( string $selector, array | callable | Expression $expression = null ) : array
$selector string field selector
$expression array | callable | Expression expression to search documents
리턴 array distinct values

getDocument() 공개 메소드

Method may return document as array if cursor configured through Cursor::asArray()
public getDocument ( string | MongoId $id, callable $callable = null ) : Document | array | null
$id string | MongoId
$callable callable cursor callable used to configure cursor
리턴 Document | array | null

getDocumentByReference() 공개 메소드

Get Document instance by it's reference
public getDocumentByReference ( array $ref, boolean $useDocumentPool = true ) : Document | null
$ref array reference to document
$useDocumentPool boolean try to get document from pool or fetch document from database
리턴 Document | null

getDocumentClassName() 공개 메소드

Override to define class name of document by document data
public getDocumentClassName ( array $documentData = null ) : string
$documentData array
리턴 string Document class data

getDocumentDirectly() 공개 메소드

Get document by id directly omitting cache Method may return document as array if cursor configured through Cursor::asArray()
public getDocumentDirectly ( string | MongoId $id, callable $callable = null ) : Document | array | null
$id string | MongoId
$callable callable cursor callable used to configure cursor
리턴 Document | array | null

getDocumentFromDocumentPool() 공개 메소드

Get document from identity map by it's id
public getDocumentFromDocumentPool ( string | integer | MongoId $id ) : Document
$id string | integer | MongoId
리턴 Document

getDocuments() 공개 메소드

Get documents by list of id
public getDocuments ( array $idList, callable $callable = null ) : array | null
$idList array list of ids
$callable callable cursor callable used to configure cursor
리턴 array | null

getDocumentsFromDocumentPool() 공개 메소드

Get documents from pool if they stored
public getDocumentsFromDocumentPool ( array $ids = null )
$ids array

getIndexes() 공개 메소드

Get index info
public getIndexes ( ) : array
리턴 array

getMongoCollection() 공개 메소드

Get native collection instance of mongo driver
public getMongoCollection ( ) : MongoCollection
리턴 MongoCollection

getName() 공개 메소드

Get name of collection
public getName ( ) : string
리턴 string name of collection

getOption() 공개 메소드

Get option
public getOption ( string | integer $name ) : mixed
$name string | integer
리턴 mixed

getOptions() 공개 메소드

public getOptions ( )

getReadPreference() 공개 메소드

public getReadPreference ( )

getWriteConcern() 공개 메소드

Get currently active write concern on all requests to collection
public getWriteConcern ( ) : integer | string
리턴 integer | string write concern

hasDocument() 공개 메소드

Check if document belongs to collection
public hasDocument ( Document $document ) : type
$document Document
리턴 type

hydrate() 공개 메소드

Factory method to get document object from array of stored document
public hydrate ( array $data, $useDocumentPool = true ) : Document
$data array
리턴 Document

initIndexes() 공개 메소드

Create indexes based on self::$_index metadata
public initIndexes ( ) : Collection
리턴 Collection

insert() 공개 메소드

Direct insert of array to MongoDB without creating document object and validation
public insert ( array $document ) : Collection
$document array
리턴 Collection

insertMultiple() 공개 메소드

사용 중단: since 1.13 Use Collection::batchInsert()
public insertMultiple ( $rows, $validate = true )

isDocumentInDocumentPool() 공개 메소드

Check if document exists in identity map
public isDocumentInDocumentPool ( Document | MongoId | integer | string $document ) : boolean
$document Document | MongoId | integer | string Document instance or it's id
리턴 boolean

isDocumentPoolEmpty() 공개 메소드

Check if documents are in pool
public isDocumentPoolEmpty ( ) : boolean
리턴 boolean

isDocumentPoolEnabled() 공개 메소드

Check if document pool enabled and requested documents store to it
public isDocumentPoolEnabled ( ) : boolean
리턴 boolean

isVersioningEnabled() 공개 메소드

Check if versioning enabled
사용 중단: since 1.13 Use 'versioning' declaration in mapping
public isVersioningEnabled ( ) : boolean
리턴 boolean

operator() 공개 메소드

Create Operator instance to use in update operations
public operator ( ) : Operator
리턴 Operator

readNearest() 공개 메소드

public readNearest ( array $tags = null )
$tags array

readPrimaryOnly() 공개 메소드

public readPrimaryOnly ( )

readPrimaryPreferred() 공개 메소드

public readPrimaryPreferred ( array $tags = null )
$tags array

readSecondaryOnly() 공개 메소드

public readSecondaryOnly ( array $tags = null )
$tags array

readSecondaryPreferred() 공개 메소드

public readSecondaryPreferred ( array $tags = null )
$tags array

removeDocumentFromDocumentPool() 공개 메소드

Remove document instance from identity map
public removeDocumentFromDocumentPool ( Document $document ) : Collection
$document Document
리턴 Collection

setMajorityWriteConcern() 공개 메소드

Define majority write concern for all requests to current collection
public setMajorityWriteConcern ( integer $timeout = 10000 ) : Collection
$timeout integer timeout in milliseconds
리턴 Collection

setUnacknowledgedWriteConcern() 공개 메소드

Define unacknowledged write concern for all requests to current collection
public setUnacknowledgedWriteConcern ( integer $timeout = 10000 ) : Collection
$timeout integer timeout in milliseconds
리턴 Collection

setWriteConcern() 공개 메소드

Define write concern for all requests to current collection
public setWriteConcern ( string | integer $w, integer $timeout = 10000 ) : Collection
$w string | integer write concern
$timeout integer timeout in milliseconds
리턴 Collection

stats() 공개 메소드

Get collection stat
public stats ( ) : array
리턴 array collection stat

update() 공개 메소드

Update multiple documents
public update ( Expression | array | callable $expression, Operator | array | callable $updateData, array $options = [] ) : Collection
$expression Expression | array | callable expression to define which documents will change.
$updateData Operator | array | callable new data or operators to update
$options array update options, see http://php.net/manual/ru/mongocollection.update.php
리턴 Collection

updateAll() 공개 메소드

Update all documents
사용 중단: since 1.13. Use Collection::batchUpdate([])
public updateAll ( Operator | array | callable $updateData ) : Collection
$updateData Operator | array | callable new data or operators
리턴 Collection

updateMultiple() 공개 메소드

사용 중단: since 1.13 Use Collection::batchUpdate()
public updateMultiple ( $expression, $updateData )

validate() 공개 메소드

Validates a collection. The method scans a collection’s data structures for correctness and returns a single document that describes the relationship between the logical collection and the physical representation of the data.
public validate ( boolean $full = false ) : array
$full boolean Specify true to enable a full validation and to return full statistics. MongoDB disables full validation by default because it is a potentially resource-intensive operation.
리턴 array

프로퍼티 상세

$_index 보호되어 있는 프로퍼티

Every index definition must contain key 'keys' with list of fields and orders, and optional options from @link http://php.net/manual/en/mongocollection.createindex.php: Example: array( array( 'keys' => array('field1' => 1, 'field2' => -1), 'unique' => true ), ... )
사용 중단: since 1.13 Use 'index' declaration in mapping
protected $_index

$_queryExpressionClass 보호되어 있는 프로퍼티

expression class. This class may be overloaded to define own query methods (whereUserAgeGreatedThan(), etc.)
사용 중단: since 1.13 Use 'expressionClass' declaration in mapping
protected $_queryExpressionClass

$mongoCollectionClassName 보호되어 있는 프로퍼티

protected $mongoCollectionClassName

$versioning 보호되어 있는 프로퍼티

default value of versioning
사용 중단: since 1.13 Use 'versioning' declaration in mapping
protected $versioning