#include <userver/storages/mongo/collection.hpp>
MongoDB collection handle, the main way to operate with MongoDB.
Usually retrieved from storages::mongo::Pool
Definition at line 34 of file collection.hpp.
Public Member Functions | |
| template<typename... Options> | |
| size_t | Count (formats::bson::Document filter, Options &&... options) const |
| Returns the number of documents matching the query. | |
| template<typename... Options> | |
| size_t | CountApprox (Options &&... options) const |
| Returns an approximated count of all documents in the collection. | |
| template<typename... Options> | |
| Cursor | Find (formats::bson::Document filter, Options &&... options) const |
| Performs a query on the collection. | |
| template<typename... Options> | |
| std::optional< formats::bson::Document > | FindOne (formats::bson::Document filter, Options &&... options) const |
| Retrieves a single document from the collection. | |
| template<typename... Options> | |
| WriteResult | InsertOne (formats::bson::Document document, Options &&... options) |
| Inserts a single document into the collection. | |
| template<typename... Options> | |
| WriteResult | InsertMany (std::vector< formats::bson::Document > documents, Options &&... options) |
| Inserts multiple documents into the collection. | |
| template<typename... Options> | |
| WriteResult | ReplaceOne (formats::bson::Document selector, formats::bson::Document replacement, Options &&... options) |
| Replaces a single matching document. | |
| template<typename... Options> | |
| WriteResult | UpdateOne (formats::bson::Document selector, formats::bson::Document update, Options &&... options) |
| Updates a single matching document. | |
| template<typename... Options> | |
| WriteResult | UpdateMany (formats::bson::Document selector, formats::bson::Document update, Options &&... options) |
| Updates all matching documents. | |
| template<typename... Options> | |
| WriteResult | DeleteOne (formats::bson::Document selector, Options &&... options) |
| Deletes a single matching document. | |
| template<typename... Options> | |
| WriteResult | DeleteMany (formats::bson::Document selector, Options &&... options) |
| Deletes all matching documents. | |
| template<typename... Options> | |
| WriteResult | FindAndModify (formats::bson::Document query, const formats::bson::Document &update, Options &&... options) |
| Atomically updates a single matching document. | |
| template<typename... Options> | |
| WriteResult | FindAndRemove (formats::bson::Document query, Options &&... options) |
| Atomically removes a single matching document. | |
| template<typename... Options> | |
| void | Drop (Options &&... options) |
| Drop collection. | |
| template<typename... Options> | |
| operations::Bulk | MakeOrderedBulk (Options &&... options) |
| Efficiently executes multiple operations in order, stops on error. | |
| template<typename... Options> | |
| operations::Bulk | MakeUnorderedBulk (Options &&... options) |
| Efficiently executes multiple operations out of order, continues on error. | |
| template<typename... Options> | |
| Cursor | Aggregate (formats::bson::Value pipeline, Options &&... options) |
| Executes an aggregation pipeline. | |
| template<typename... Options> | |
| std::vector< formats::bson::Value > | Distinct (std::string field, Options &&... options) const |
| Retrieves distinct values for a specified field. | |
| template<typename... Options> | |
| std::vector< formats::bson::Value > | Distinct (std::string field, formats::bson::Document filter, Options &&... options) const |
| Retrieves distinct values for a specified field with a query filter. | |
| const std::string & | GetCollectionName () const |
| Get collection name. | |
Prepared operation executors | |
| size_t | Execute (const operations::Count &) const |
| size_t | Execute (const operations::CountApprox &) const |
| Cursor | Execute (const operations::Find &) const |
| std::vector< formats::bson::Value > | Execute (const operations::Distinct &) const |
| WriteResult | Execute (const operations::InsertOne &) |
| WriteResult | Execute (const operations::InsertMany &) |
| WriteResult | Execute (const operations::ReplaceOne &) |
| WriteResult | Execute (const operations::Update &) |
| WriteResult | Execute (const operations::Delete &) |
| WriteResult | Execute (const operations::FindAndModify &) |
| WriteResult | Execute (const operations::FindAndRemove &) |
| WriteResult | Execute (operations::Bulk &&) |
| Cursor | Execute (const operations::Aggregate &) |
| void | Execute (const operations::Drop &) |
| Cursor storages::mongo::Collection::Aggregate | ( | formats::bson::Value | pipeline, |
| Options &&... | options ) |
Executes an aggregation pipeline.
| pipeline | an array of aggregation operations |
| options | see storages::mongo::options |
Definition at line 288 of file collection.hpp.
| size_t storages::mongo::Collection::Count | ( | formats::bson::Document | filter, |
| Options &&... | options ) const |
Returns the number of documents matching the query.
Definition at line 159 of file collection.hpp.
| size_t storages::mongo::Collection::CountApprox | ( | Options &&... | options | ) | const |
Returns an approximated count of all documents in the collection.
Definition at line 166 of file collection.hpp.
| WriteResult storages::mongo::Collection::DeleteMany | ( | formats::bson::Document | selector, |
| Options &&... | options ) |
Deletes all matching documents.
Definition at line 245 of file collection.hpp.
| WriteResult storages::mongo::Collection::DeleteOne | ( | formats::bson::Document | selector, |
| Options &&... | options ) |
Deletes a single matching document.
Definition at line 238 of file collection.hpp.
| std::vector< formats::bson::Value > storages::mongo::Collection::Distinct | ( | std::string | field, |
| formats::bson::Document | filter, | ||
| Options &&... | options ) const |
Retrieves distinct values for a specified field with a query filter.
| field | name of the field for which to return distinct values |
| filter | query that specifies the documents from which to retrieve distinct values |
| options | see storages::mongo::options |
Definition at line 303 of file collection.hpp.
| std::vector< formats::bson::Value > storages::mongo::Collection::Distinct | ( | std::string | field, |
| Options &&... | options ) const |
Retrieves distinct values for a specified field.
| field | name of the field for which to return distinct values |
| options | see storages::mongo::options |
Definition at line 295 of file collection.hpp.
| void storages::mongo::Collection::Drop | ( | Options &&... | options | ) |
Drop collection.
Definition at line 267 of file collection.hpp.
| Cursor storages::mongo::Collection::Find | ( | formats::bson::Document | filter, |
| Options &&... | options ) const |
Performs a query on the collection.
Definition at line 183 of file collection.hpp.
| WriteResult storages::mongo::Collection::FindAndModify | ( | formats::bson::Document | query, |
| const formats::bson::Document & | update, | ||
| Options &&... | options ) |
Atomically updates a single matching document.
Definition at line 253 of file collection.hpp.
| WriteResult storages::mongo::Collection::FindAndRemove | ( | formats::bson::Document | query, |
| Options &&... | options ) |
Atomically removes a single matching document.
Definition at line 260 of file collection.hpp.
| std::optional< formats::bson::Document > storages::mongo::Collection::FindOne | ( | formats::bson::Document | filter, |
| Options &&... | options ) const |
Retrieves a single document from the collection.
Definition at line 190 of file collection.hpp.
| WriteResult storages::mongo::Collection::InsertMany | ( | std::vector< formats::bson::Document > | documents, |
| Options &&... | options ) |
Inserts multiple documents into the collection.
Definition at line 207 of file collection.hpp.
| WriteResult storages::mongo::Collection::InsertOne | ( | formats::bson::Document | document, |
| Options &&... | options ) |
Inserts a single document into the collection.
Definition at line 200 of file collection.hpp.
| operations::Bulk storages::mongo::Collection::MakeOrderedBulk | ( | Options &&... | options | ) |
Efficiently executes multiple operations in order, stops on error.
Definition at line 274 of file collection.hpp.
| operations::Bulk storages::mongo::Collection::MakeUnorderedBulk | ( | Options &&... | options | ) |
Efficiently executes multiple operations out of order, continues on error.
Definition at line 281 of file collection.hpp.
| WriteResult storages::mongo::Collection::ReplaceOne | ( | formats::bson::Document | selector, |
| formats::bson::Document | replacement, | ||
| Options &&... | options ) |
Replaces a single matching document.
Definition at line 215 of file collection.hpp.
| WriteResult storages::mongo::Collection::UpdateMany | ( | formats::bson::Document | selector, |
| formats::bson::Document | update, | ||
| Options &&... | options ) |
Updates all matching documents.
Definition at line 231 of file collection.hpp.
| WriteResult storages::mongo::Collection::UpdateOne | ( | formats::bson::Document | selector, |
| formats::bson::Document | update, | ||
| Options &&... | options ) |
Updates a single matching document.
Definition at line 223 of file collection.hpp.