ORM C++
Loading...
Searching...
No Matches
orm::Database Class Reference

A class representing a database in the ORM framework. More...

#include <database.hpp>

Public Types

template<typename T >
using Payload = db::binding::BindingPayload<T>
 

Public Member Functions

 Database ()
 Constructs a new Database object.
 
auto connect (const std::string &connectionString) -> void
 Connects to a database.
 
auto disconnect () -> void
 Disconnects from the database.
 
template<typename T >
auto select (Query< T > &query) -> std::vector< T >
 Executes a select query and returns the result.
 
template<typename T >
auto insert (const std::vector< T > &objects) -> void
 Executes a insert query for multiple objects.
 
template<typename T >
auto insert (T object) -> void
 Executes a insert query for a single object.
 
template<typename T >
auto createTable () -> void
 Execute a create table query for a model.
 
template<typename T >
auto deleteTable () -> void
 Execute a delete table query for a model.
 
auto getBackendType () -> db::BackendType
 Get the backend type of the database.
 
auto beginTransaction () -> void
 Starts a transaction.
 
auto commitTransaction () -> void
 Commits a transaction.
 
auto rollbackTransaction () -> void
 Rollbacks a transaction.
 

Detailed Description

A class representing a database in the ORM framework.

This class provides functionality for connecting to a database and executing queries.

Member Function Documentation

◆ connect()

auto orm::Database::connect ( const std::string & connectionString) -> void

Connects to a database.

Parameters
connectionStringThe connection string for the database.

◆ createTable()

template<typename T >
auto orm::Database::createTable ( ) -> void
inline

Execute a create table query for a model.

Template Parameters
TThe type of the model which table to will be created.

◆ deleteTable()

template<typename T >
auto orm::Database::deleteTable ( ) -> void
inline

Execute a delete table query for a model.

Template Parameters
TThe type of the model which table to will be deleted.

◆ getBackendType()

auto orm::Database::getBackendType ( ) -> db::BackendType

Get the backend type of the database.

Returns
The backend type of the database.

◆ insert() [1/2]

template<typename T >
auto orm::Database::insert ( const std::vector< T > & objects) -> void
inline

Executes a insert query for multiple objects.

Template Parameters
TThe type of the query.
Parameters
objectsThe vector of objects of type T to insert.

◆ insert() [2/2]

template<typename T >
auto orm::Database::insert ( T object) -> void
inline

Executes a insert query for a single object.

Template Parameters
TThe type of the query.
Parameters
objectThe object of type T to insert.

◆ select()

template<typename T >
auto orm::Database::select ( Query< T > & query) -> std::vector<T>
inline

Executes a select query and returns the result.

Template Parameters
TThe type of the query model.
Parameters
queryThe select query of type T to execute.
Returns
The vector of objects of type T returned by the select query.

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