Свойство | Type | Description | |
---|---|---|---|
$database | MongoDB database instance. | ||
$name | name of this collection. |
Méthode | Description | |
---|---|---|
aggregate ( array $pipelines, array $options = [] ) : array | Performs aggregation using Mongo Aggregation Framework. | |
batchInsert ( array $rows, array $options = [] ) : array | Inserts several new rows into collection. | |
count ( array $condition = [], array $options = [] ) : integer | Counts records in this collection. | |
createIndex ( array | string $columns, array $options = [] ) : boolean | Creates an index on the collection and the specified fields. | |
createIndexes ( array $indexes ) : boolean | Creates several indexes at once. | |
distinct ( string $column, array $condition = [], array $options = [] ) : array | boolean | Returns a list of distinct values for the given column across a collection. | |
drop ( ) : boolean | Drops this collection. | |
dropAllIndexes ( ) : integer | Drops all indexes for this collection. | |
dropIndex ( string | array $columns ) : boolean | Drop indexes for specified column(s). | |
dropIndexes ( string $indexes ) : integer | Drops collection indexes by name. | |
find ( array $condition = [], array $fields = [], array $options = [] ) : MongoDB\Driver\Cursor | Returns a cursor for the search results. | |
findAndModify ( array $condition, array $update, array $options = [] ) : array | null | Updates a document and returns it. | |
findOne ( array $condition = [], array $fields = [], array $options = [] ) : array | null | Returns a single document. | |
getFullName ( ) : string | ||
group ( mixed $keys, array $initial, MongoDB\BSON\Javascript | string $reduce, array $options = [] ) : array | Performs aggregation using Mongo "group" command. | |
insert ( array | object $data, array $options = [] ) : MongoDB\BSON\ObjectID | Inserts new data into collection. | |
listIndexes ( array $options = [] ) : array | Returns the list of defined indexes. | |
mapReduce ( MongoDB\BSON\Javascript | string $map, MongoDB\BSON\Javascript | string $reduce, string | array $out, array $condition = [], array $options = [] ) : string | array | Performs aggregation using MongoDB "map-reduce" mechanism. | |
remove ( array $condition = [], array $options = [] ) : integer | boolean | Removes data from the collection. | |
save ( array | object $data, array $options = [] ) : MongoId | Update the existing database data, otherwise insert this data | |
update ( array $condition, array $newData, array $options = [] ) : integer | boolean | Updates the rows, which matches given criteria by given data. |
public createIndex ( array | string $columns, array $options = [] ) : boolean | ||
$columns | array | string | column name or list of column names. If array is given, each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort. You can specify field using native numeric key with the field name as a value, in this case ascending sort will be used. For example: ```php [ 'name', 'status' => -1, ] ``` |
$options | array | list of options in format: optionName => optionValue. |
Résultat | boolean | whether the operation successful. |
public createIndexes ( array $indexes ) : boolean | ||
$indexes | array | indexes specification, each index should be specified as an array. |
Résultat | boolean | whether operation was successful. |
public distinct ( string $column, array $condition = [], array $options = [] ) : array | boolean | ||
$column | string | column to use. |
$condition | array | query parameters. |
$options | array | list of options in format: optionName => optionValue. |
Résultat | array | boolean | array of distinct values, or "false" on failure. |
public dropAllIndexes ( ) : integer | ||
Résultat | integer | count of dropped indexes. |
public dropIndex ( string | array $columns ) : boolean | ||
$columns | string | array | column name or list of column names. If array is given, each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort. Use value 'text' to specify text index. You can specify field using native numeric key with the field name as a value, in this case ascending sort will be used. For example: ```php [ 'name', 'status' => -1, 'description' => 'text', ] ``` |
Résultat | boolean | whether the operation successful. |
public dropIndexes ( string $indexes ) : integer | ||
$indexes | string | wildcard for name of the indexes to be dropped. You can use `*` to drop all indexes. |
Résultat | integer | count of dropped indexes. |
public findAndModify ( array $condition, array $update, array $options = [] ) : array | null | ||
$condition | array | query condition |
$update | array | update criteria |
$options | array | list of options in format: optionName => optionValue. |
Résultat | array | null | the original document, or the modified document when $options['new'] is set. |
public findOne ( array $condition = [], array $fields = [], array $options = [] ) : array | null | ||
$condition | array | query condition |
$fields | array | fields to be selected |
$options | array | query options (available since 2.1). |
Résultat | array | null | the single document. Null is returned if the query results in nothing. |
public getFullName ( ) : string | ||
Résultat | string | full name of this collection, including database name. |
public group ( mixed $keys, array $initial, MongoDB\BSON\Javascript | string $reduce, array $options = [] ) : array | ||
$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. |
Résultat | array | the result of the aggregation. |
public listIndexes ( array $options = [] ) : array | ||
$options | array | list of options in format: optionName => optionValue. |
Résultat | array | list of indexes info. |
public mapReduce ( MongoDB\BSON\Javascript | string $map, MongoDB\BSON\Javascript | string $reduce, string | array $out, array $condition = [], array $options = [] ) : string | array | ||
$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 | criteria 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. |
Résultat | string | array | the map reduce output collection name or output results. |
public update ( array $condition, array $newData, array $options = [] ) : integer | boolean | ||
$condition | array | description of the objects to update. |
$newData | array | the object with which to update the matching records. |
$options | array | list of options in format: optionName => optionValue. |
Résultat | integer | boolean | number of updated documents or whether operation was successful. |