Skip to content

CosmosClient Class Reference

Defined in siddiqsoft/cosmoscl.hpp inside namespace siddiqsoft.

class CosmosClient;

Member Functions

Configuration & Connection

configure

CosmosConnection configure(const nlohmann::json& config);
Configures the client with connection strings and partition key names.

primaryEndpoint

const CosmosEndpoint& primaryEndpoint() const;
Returns the configured CosmosEndpoint.


Document Operations

createDocument

CosmosResponseType createDocument(const CosmosArgumentType& arg);
Creates a new document in the specified database and container.

readDocument

CosmosResponseType readDocument(const CosmosArgumentType& arg);
Reads a document by id and partitionKey.

replaceDocument

CosmosResponseType replaceDocument(const CosmosArgumentType& arg);
Replaces an existing document.

deleteDocument

CosmosResponseType deleteDocument(const CosmosArgumentType& arg);
Deletes a document by id and partitionKey.


Query Operations

queryDocuments

CosmosResponseType queryDocuments(const CosmosArgumentType& arg);
Executes a SQL query against the container.

queryDocumentsIterable

CosmosIterableResponseType queryDocumentsIterable(const CosmosArgumentType& arg);
Returns an iterable response structure for navigating multi-page query results.


Database Operations

createDatabase / getDatabase / listDatabases / deleteDatabase

CosmosResponseType createDatabase(const CosmosArgumentType& arg);
CosmosResponseType getDatabase(const CosmosArgumentType& arg);
CosmosResponseType listDatabases(const CosmosArgumentType& arg);
CosmosResponseType deleteDatabase(const CosmosArgumentType& arg);

Container Operations

createContainer / getContainer / listContainers / deleteContainer

CosmosResponseType createContainer(const CosmosArgumentType& arg);
CosmosResponseType getContainer(const CosmosArgumentType& arg);
CosmosResponseType listContainers(const CosmosArgumentType& arg);
CosmosResponseType deleteContainer(const CosmosArgumentType& arg);

Asynchronous Execution

sendAsync

void sendAsync(
    CosmosOperation op,
    CosmosArgumentType arg,
    std::function<void(CosmosResponseType)> callback
);
Dispatches the operation to a background worker thread pool and invokes callback upon completion.