Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
database::MongoClient Class Reference

An asynchronous MongoDB client using coroutines. More...

#include <MongoClient.hpp>

Classes

struct  Config
 Configuration options for the MongoDB client. More...
 
struct  InsertAwaiter
 
struct  QueryAwaiter
 
struct  QueryResult
 

Public Member Functions

 MongoClient (concurrency::ThreadPool &thread_pool, const Config &config)
 Constructs a new MongoClient.
 
 ~MongoClient ()
 
 MongoClient (const MongoClient &)=delete
 
MongoClientoperator= (const MongoClient &)=delete
 
QueryAwaiter find_async (std::string query_json)
 Executes a find query asynchronously.
 
InsertAwaiter insert_async (std::string doc_json)
 Inserts a document asynchronously.
 
concurrency::ThreadPoolget_thread_pool ()
 Gets the associated thread pool.
 
mongoc_client_pool_t * get_pool ()
 Gets the underlying MongoDB client pool.
 
const Configget_config () const
 Gets the configuration used by this client.
 

Detailed Description

An asynchronous MongoDB client using coroutines.

Constructor & Destructor Documentation

◆ MongoClient() [1/2]

database::MongoClient::MongoClient ( concurrency::ThreadPool thread_pool,
const Config config 
)

Constructs a new MongoClient.

Parameters
thread_poolThe thread pool to use for asynchronous operations.
configThe configuration settings for the MongoDB client.

◆ ~MongoClient()

database::MongoClient::~MongoClient ( )

◆ MongoClient() [2/2]

database::MongoClient::MongoClient ( const MongoClient )
delete

Member Function Documentation

◆ find_async()

MongoClient::QueryAwaiter database::MongoClient::find_async ( std::string  query_json)

Executes a find query asynchronously.

Parameters
query_jsonThe JSON string representing the query.
Returns
A QueryAwaiter that can be co_awaited for the result.
auto result = co_await client.find_async("{\"name\": \"test\"}");

◆ get_config()

const Config & database::MongoClient::get_config ( ) const
inline

Gets the configuration used by this client.

Returns
Constant reference to the configuration.

◆ get_pool()

mongoc_client_pool_t * database::MongoClient::get_pool ( )
inline

Gets the underlying MongoDB client pool.

Returns
Pointer to the mongoc_client_pool_t instance.

◆ get_thread_pool()

concurrency::ThreadPool & database::MongoClient::get_thread_pool ( )
inline

Gets the associated thread pool.

Returns
Reference to the thread pool.

◆ insert_async()

MongoClient::InsertAwaiter database::MongoClient::insert_async ( std::string  doc_json)

Inserts a document asynchronously.

Parameters
doc_jsonThe JSON string representing the document to insert.
Returns
An InsertAwaiter that can be co_awaited for success status.

◆ operator=()

MongoClient & database::MongoClient::operator= ( const MongoClient )
delete

The documentation for this class was generated from the following files: