프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$databaseName | name of the database that this command is associated with. | ||
$db | the MongoDB connection that this command is associated with. | ||
$document | command document contents. |
메소드 | 설명 | |
---|---|---|
addDelete ( array $condition, array $options = [] ) | Adds the delete operation to the batch command. | |
addInsert ( array $document ) | Adds the insert operation to the batch command. | |
addUpdate ( array $condition, array $document, array $options = [] ) | Adds the update operation to the batch command. | |
aggregate ( string $collectionName, array $pipelines, array $options = [] ) : array | Performs aggregation using MongoDB Aggregation Framework. | |
batchInsert ( string $collectionName, array[] $documents, array $options = [] ) : array | false | Inserts batch of new documents into collection. | |
count ( string $collectionName, array $condition = [], array $options = [] ) : integer | Counts records in specified collection. | |
createCollection ( string $collectionName, array $options = [] ) : boolean | Creates new collection in database associated with this command.s | |
createIndexes ( string $collectionName, array[] $indexes ) : boolean | Creates indexes in the collection. | |
delete ( string $collectionName, array $condition, array $options = [] ) : MongoDB\Driver\WriteResult | Removes documents from the collection. | |
distinct ( string $collectionName, string $fieldName, array $condition = [], array $options = [] ) : array | Returns a list of distinct values for the given column across a collection. | |
dropCollection ( string $collectionName ) : boolean | Drops specified collection. | |
dropDatabase ( ) : boolean | Drops database associated with this command. | |
dropIndexes ( string $collectionName, string $indexes ) : array | Drops collection indexes by name. | |
execute ( ) : MongoDB\Driver\Cursor | Executes this command. | |
executeBatch ( string $collectionName, array $options = [] ) : array | Execute commands batch (bulk). | |
explain ( string $collectionName, array $query ) : array | Return an explanation of the query, often useful for optimization and debugging. | |
find ( string $collectionName, array $condition, array $options = [] ) : MongoDB\Driver\Cursor | Performs find query. | |
findAndModify ( $collectionName, array $condition = [], array $update = [], array $options = [] ) : array | null | Updates a document and returns it. | |
getReadConcern ( ) : MongoDB\Driver\ReadConcern | string | Retuns read concern for this command. | |
getReadPreference ( ) : MongoDB\Driver\ReadPreference | Returns read preference for this command. | |
getWriteConcern ( ) : MongoDB\Driver\WriteConcern | null | Returns write concern for this command. | |
group ( string $collectionName, mixed $keys, array $initial, MongoDB\BSON\Javascript | string $reduce, array $options = [] ) : array | Performs aggregation using MongoDB "group" command. | |
insert ( string $collectionName, array $document, array $options = [] ) : MongoDB\BSON\ObjectID | boolean | Inserts new document into collection. | |
listCollections ( array $condition = [], array $options = [] ) : array | Returns the list of available collections. | |
listDatabases ( array $condition = [], array $options = [] ) : array | Returns the list of available databases. | |
listIndexes ( string $collectionName, array $options = [] ) : array | Returns information about current collection indexes. | |
mapReduce ( string $collectionName, MongoDB\BSON\Javascript | string $map, MongoDB\BSON\Javascript | string $reduce, string | array $out, array $condition = [], array $options = [] ) : string | array | Performs MongoDB "map-reduce" command. | |
query ( string $collectionName, array $options = [] ) : MongoDB\Driver\Cursor | Executes this command as a mongo query | |
setReadConcern ( MongoDB\Driver\ReadConcern | string $readConcern ) | Sets read concern for this command. | |
setReadPreference ( MongoDB\Driver\ReadPreference | integer | string | null $readPreference ) | Sets read preference for this command. | |
setWriteConcern ( MongoDB\Driver\WriteConcern | integer | string | null $writeConcern ) | Sets write concern for this command. | |
update ( string $collectionName, array $condition, array $document, array $options = [] ) : MongoDB\Driver\WriteResult | Update existing documents in the collection. |
메소드 | 설명 | |
---|---|---|
beginProfile ( string $token, string $category ) | Marks the beginning of a code block for profiling. | |
endProfile ( string $token, string $category ) | Marks the end of a code block for profiling. | |
log ( array | string $namespace, array $data, string $category ) : string | false | Logs the command data if logging is enabled at [[db]]. |
public batchInsert ( string $collectionName, array[] $documents, array $options = [] ) : array | false | ||
$collectionName | string | collection name |
$documents | array[] | documents list |
$options | array | list of options in format: optionName => optionValue. |
리턴 | array | false | list of inserted IDs, `false` on failure. |
protected beginProfile ( string $token, string $category ) | ||
$token | string | token for the code block |
$category | string | the category of this log message |
public createIndexes ( string $collectionName, array[] $indexes ) : boolean | ||
$collectionName | string | collection name. |
$indexes | array[] | indexes specification. Each specification should be an array in format: optionName => value The main options are: - keys: array, column names with sort order, to be indexed. This option is mandatory. - unique: bool, whether to create unique index. - name: string, the name of the index, if not set it will be generated automatically. - background: bool, whether to bind index in the background. - sparse: bool, whether index should reference only documents with the specified field. See [[https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options-for-all-index-types]] for the full list of options. |
리턴 | boolean | whether operation was successful. |
public distinct ( string $collectionName, string $fieldName, array $condition = [], array $options = [] ) : array | ||
$collectionName | string | collection name. |
$fieldName | string | field name to use. |
$condition | array | query parameters. |
$options | array | list of options in format: optionName => optionValue. |
리턴 | array | array of distinct values, or "false" on failure. |
public dropCollection ( string $collectionName ) : boolean | ||
$collectionName | string | name of the collection to be dropped. |
리턴 | boolean | whether operation was successful. |
public dropDatabase ( ) : boolean | ||
리턴 | boolean | whether operation was successful. |
protected endProfile ( string $token, string $category ) | ||
$token | string | token for the code block |
$category | string | the category of this log message |
public execute ( ) : MongoDB\Driver\Cursor | ||
리턴 | MongoDB\Driver\Cursor | result cursor. |
public findAndModify ( $collectionName, array $condition = [], array $update = [], array $options = [] ) : array | null | ||
$collectionName | ||
$condition | array | query condition |
$update | array | update criteria |
$options | array | list of options in format: optionName => optionValue. |
리턴 | array | null | the original document, or the modified document when $options['new'] is set. |
public getReadConcern ( ) : MongoDB\Driver\ReadConcern | string | ||
리턴 | MongoDB\Driver\ReadConcern | string | read concern to be used in this command. |
public getReadPreference ( ) : MongoDB\Driver\ReadPreference | ||
리턴 | MongoDB\Driver\ReadPreference | read preference. |
public getWriteConcern ( ) : MongoDB\Driver\WriteConcern | null | ||
리턴 | MongoDB\Driver\WriteConcern | null | write concern to be used in this command. |
public group ( string $collectionName, mixed $keys, array $initial, MongoDB\BSON\Javascript | string $reduce, array $options = [] ) : array | ||
$collectionName | string | collection name. |
$keys | mixed | fields to group by. If an array or non-code object is passed, it will be the key used to group results. If instance of [[\MongoDB\BSON\Javascript]] passed, it will be treated as a function that returns the key to group by. |
$initial | array | Initial value of the aggregation counter object. |
$reduce | MongoDB\BSON\Javascript | string | function that takes two arguments (the current document and the aggregation to this point) and does the aggregation. Argument will be automatically cast to [[\MongoDB\BSON\Javascript]]. |
$options | array | optional parameters to the group command. Valid options include: - condition - criteria for including a document in the aggregation. - finalize - function called once per unique key that takes the final output of the reduce function. |
리턴 | array | the result of the aggregation. |
public insert ( string $collectionName, array $document, array $options = [] ) : MongoDB\BSON\ObjectID | boolean | ||
$collectionName | string | collection name |
$document | array | document content |
$options | array | list of options in format: optionName => optionValue. |
리턴 | MongoDB\BSON\ObjectID | boolean | inserted record ID, `false` - on failure. |
public mapReduce ( string $collectionName, MongoDB\BSON\Javascript | string $map, MongoDB\BSON\Javascript | string $reduce, string | array $out, array $condition = [], array $options = [] ) : string | array | ||
$collectionName | string | collection name. |
$map | MongoDB\BSON\Javascript | string | function, which emits map data from collection. Argument will be automatically cast to [[\MongoDB\BSON\Javascript]]. |
$reduce | MongoDB\BSON\Javascript | string | function that takes two arguments (the map key and the map values) and does the aggregation. Argument will be automatically cast to [[\MongoDB\BSON\Javascript]]. |
$out | string | array | output collection name. It could be a string for simple output ('outputCollection'), or an array for parametrized output (['merge' => 'outputCollection']). You can pass ['inline' => true] to fetch the result at once without temporary collection usage. |
$condition | array | filter condition for including a document in the aggregation. |
$options | array | additional optional parameters to the mapReduce command. Valid options include: - sort: array, key to sort the input documents. The sort key must be in an existing index for this collection. - limit: int, the maximum number of documents to return in the collection. - finalize: \MongoDB\BSON\Javascript|string, function, which follows the reduce method and modifies the output. - scope: array, specifies global variables that are accessible in the map, reduce and finalize functions. - jsMode: bool, specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions. - verbose: bool, specifies whether to include the timing information in the result information. |
리턴 | string | array | the map reduce output collection name or output results. |
public setReadConcern ( MongoDB\Driver\ReadConcern | string $readConcern ) | ||
$readConcern | MongoDB\Driver\ReadConcern | string | read concern, it can be an instance of [[ReadConcern]] or scalar level value, for example: 'local'. |
public setReadPreference ( MongoDB\Driver\ReadPreference | integer | string | null $readPreference ) | ||
$readPreference | MongoDB\Driver\ReadPreference | integer | string | null | read reference, it can be specified as instance of [[ReadPreference]] or scalar mode value, for example: `ReadPreference::RP_PRIMARY`. |
public update ( string $collectionName, array $condition, array $document, array $options = [] ) : MongoDB\Driver\WriteResult | ||
$collectionName | string | collection name |
$condition | array | filter condition |
$document | array | data to be updated. |
$options | array | update options. |
리턴 | MongoDB\Driver\WriteResult | write result. |
public $databaseName |