#include <userver/storages/mongo/pool.hpp>
MongoDB client pool.
Use constructor only for tests, in production the pool should be retrieved from the components via components::Mongo::GetPool() or components::MultiMongo::GetPool().
Example usage:
});
auto cursor = in_coll.Aggregate(
),
);
EXPECT_FALSE(cursor);
EXPECT_EQ(2, out_coll.CountApprox());
for (const auto& doc : out_coll.Find({})) {
EXPECT_EQ(doc["_id"].As<int>(), doc["x"].As<int>() + 1);
EXPECT_TRUE(doc["check"].As<bool>());
}
}
Definition at line 37 of file pool.hpp.
|
|
| Pool (Pool &&) noexcept |
| |
|
Pool & | operator= (Pool &&) noexcept |
| |
|
bool | HasCollection (utils::zstring_view name) const |
| | Checks whether a collection exists.
|
| |
|
Collection | GetCollection (std::string name) const |
| | Returns a handle for the specified collection.
|
| |
| void | DropDatabase () |
| |
|
std::vector< std::string > | ListCollectionNames () const |
| | Get a list of all the collection names in the associated database.
|
| |
| void | Ping () |
| |
| Transaction | BeginTransaction () const |
| | Begin a new transaction.
|
| |
◆ BeginTransaction()
| Transaction storages::mongo::Pool::BeginTransaction |
( |
| ) |
const |
Begin a new transaction.
- Returns
- Transaction handle for executing operations within transaction context
- Exceptions
-
◆ DropDatabase()
| void storages::mongo::Pool::DropDatabase |
( |
| ) |
|
Drops the associated database if it exists. New modifications of collections will attempt to re-create the database automatically.
◆ Ping()
| void storages::mongo::Pool::Ping |
( |
| ) |
|
The documentation for this class was generated from the following file: