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

Public Member Functions

template<db::ConnectionConfiguration Config>
 Database (const Config &config, db::CommandGeneratorFactory registry={})
 Constructs a new Database object.
 ~Database () noexcept
 Database (const Database &)=delete
 Database (Database &&)=delete
auto operator= (const Database &) -> Database &=delete
auto operator= (Database &&) -> Database &=delete
template<db::ConnectionConfiguration Config>
auto connect (const Config &config) -> void
 Connects to a database.
auto disconnect () -> void
 Disconnects from the database.
template<typename SchemaType>
auto orm () &noexcept -> OrmContext< SchemaType >
template<typename SchemaType>
auto orm () &&-> OrmContext< SchemaType >=delete
auto getBackendType () const noexcept -> db::BackendType
 Get the backend type of the database.
auto isConnected () const noexcept -> bool
 Returns whether a backend session is currently open.
auto getBackendCapabilities () const -> const db::BackendCapabilities &
 Returns the capabilities advertised by the connected backend.
auto scopedTransaction () &-> ScopedTransaction
auto beginTransaction () -> void
 Starts a transaction.
auto commitTransaction () -> void
 Commits a transaction.
auto rollbackTransaction () -> void
 Rollbacks a transaction.

Friends

class ScopedTransaction
template<typename>
class OrmContext

Detailed Description

Definition at line 47 of file connection.cppm.

Constructor & Destructor Documentation

◆ Database() [1/3]

template<db::ConnectionConfiguration Config>
orm::Database::Database ( const Config & config,
db::CommandGeneratorFactory registry = {} )
inlineexplicit

Constructs a new Database object.

Definition at line 54 of file connection.cppm.

◆ ~Database()

orm::Database::~Database ( )
noexcept

◆ Database() [2/3]

orm::Database::Database ( const Database & )
delete

◆ Database() [3/3]

orm::Database::Database ( Database && )
delete

Member Function Documentation

◆ beginTransaction()

auto orm::Database::beginTransaction ( ) -> void

Starts a transaction.

◆ commitTransaction()

auto orm::Database::commitTransaction ( ) -> void

Commits a transaction.

◆ connect()

template<db::ConnectionConfiguration Config>
auto orm::Database::connect ( const Config & config) -> void
inline

Connects to a database.

Parameters
configThe typed connection parameters, borrowed during opening.

Definition at line 70 of file connection.cppm.

◆ disconnect()

auto orm::Database::disconnect ( ) -> void

Disconnects from the database.

◆ getBackendCapabilities()

auto orm::Database::getBackendCapabilities ( ) const -> const db::BackendCapabilities &
nodiscard

Returns the capabilities advertised by the connected backend.

Exceptions
DatabaseErrorwhen no backend is connected.

◆ getBackendType()

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

Get the backend type of the database.

Returns
The backend type of the database.

◆ isConnected()

auto orm::Database::isConnected ( ) const -> bool
nodiscardnoexcept

Returns whether a backend session is currently open.

◆ operator=() [1/2]

auto orm::Database::operator= ( const Database & ) -> Database &=delete
delete

◆ operator=() [2/2]

auto orm::Database::operator= ( Database && ) -> Database &=delete
delete

◆ orm() [1/2]

template<typename SchemaType>
auto orm::Database::orm ( ) && -> OrmContext< SchemaType >=delete
delete

◆ orm() [2/2]

template<typename SchemaType>
auto orm::Database::orm ( ) & -> OrmContext< SchemaType >
inlinenodiscardnoexcept

Creates a borrowed ORM context. This Database must outlive the context.

Definition at line 82 of file connection.cppm.

◆ rollbackTransaction()

auto orm::Database::rollbackTransaction ( ) -> void

Rollbacks a transaction.

◆ scopedTransaction()

auto orm::Database::scopedTransaction ( ) & -> ScopedTransaction
nodiscard

Starts a transaction that rolls back on scope exit unless explicitly finished.

◆ OrmContext

template<typename>
friend class OrmContext
friend

Definition at line 132 of file connection.cppm.

◆ ScopedTransaction

friend class ScopedTransaction
friend

Definition at line 129 of file connection.cppm.


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