Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::orm Namespace Reference

Namespaces

namespace  detail
 

Classes

class  Col
 A database column, allowing C++ operators to build parameterized SQL conditions. More...
 
class  DatabaseError
 A query run by the ORM failed, or its rows did not fit the model. More...
 
struct  Expr
 A SQL condition with ? placeholders and the values bound to them. More...
 
struct  MigrationResult
 Database migration runner (PostgreSQL) More...
 
class  MigrationRunner
 
struct  MongoGetAwaiter
 An awaiter for MongoDB queries that maps JSON responses back to C++ ModelType vectors. More...
 
struct  MongoInsertAwaiter
 An awaiter for MongoDB inserts. More...
 
class  MongoQueryBuilder
 A lightweight ORM builder for MongoDB using nlohmann::json. More...
 
class  QueryBuilder
 A lightweight, JSON-backed ORM Query Builder with bound parameters. More...
 
struct  QueryCountAwaiter
 
struct  QueryCreateAwaiter
 Resumes with the row an INSERT ... RETURNING * stored. More...
 
struct  QueryGetAwaiter
 
struct  QueryInsertAwaiter
 
struct  Statement
 A statement with ? placeholders and the values bound to them. More...
 

Typedefs

using Params = std::vector< std::optional< std::string > >
 Values bound to the ? placeholders of an expression, in order. std::nullopt binds SQL NULL.
 

Enumerations

enum class  Order { Asc , Desc }
 Sort direction for QueryBuilder::order_by(). More...
 

Functions

MigrationResult migrate_sync (const std::string &conninfo, const std::string &migrations_dir, std::chrono::milliseconds timeout=std::chrono::minutes(5))
 Connects to PostgreSQL and applies the pending migrations in migrations_dir, blocking until done: for start-up, before App::listen(), or a separate migrate command.
 
template<typename DBClient >
constexpr bool is_mysql_client ()
 Runs sql (with ? placeholders) on either client type.
 
template<typename DBClient >
auto do_query_async (std::shared_ptr< DBClient > client, const std::string &sql, const Params &params)
 

Typedef Documentation

◆ Params

using orbit::orm::Params = typedef std::vector<std::optional<std::string> >

Values bound to the ? placeholders of an expression, in order. std::nullopt binds SQL NULL.

Enumeration Type Documentation

◆ Order

enum class orbit::orm::Order
strong

Sort direction for QueryBuilder::order_by().

Enumerator
Asc 
Desc 

Function Documentation

◆ do_query_async()

template<typename DBClient >
auto orbit::orm::do_query_async ( std::shared_ptr< DBClient >  client,
const std::string &  sql,
const Params &  params 
)

◆ is_mysql_client()

template<typename DBClient >
constexpr bool orbit::orm::is_mysql_client ( )
constexpr

Runs sql (with ? placeholders) on either client type.

PostgreSQL binds the values as real parameters. MariaDB/MySQL clients, whose non-blocking API has no parameter binding here, receive literals escaped with mysql_real_escape_string. True for clients speaking MySQL/MariaDB (they escape rather than bind).

◆ migrate_sync()

MigrationResult orbit::orm::migrate_sync ( const std::string &  conninfo,
const std::string &  migrations_dir,
std::chrono::milliseconds  timeout = std::chrono::minutes(5) 
)
inline

Connects to PostgreSQL and applies the pending migrations in migrations_dir, blocking until done: for start-up, before App::listen(), or a separate migrate command.

Runs its own short-lived event loop on the calling thread, so it needs no App or server. Gives up after timeout with an error result.