载入中...
搜索中...
未找到
eve::database::Connection类 参考

SQLite connection with a small ORM layer on top of Poco::Data. Tables/columns are quoted identifiers; values are bound as literals. 更多...

#include <Database.h>

Public 成员函数

 Connection (std::string connector, std::string connectionString)
 Opens a Poco::Data session; connector is e.g. "SQLite".
 
 ~Connection ()
 Connection.
 
 Connection (const Connection &)=delete
 
Connection & operator= (const Connection &)=delete
 
bool isConnected () const
 True while the underlying session is open.
 
void close ()
 Closes the session (idempotent).
 
int execute (const std::string &sql)
 Executes a statement; returns the affected row count.
 
std::vector< Row > query (const std::string &sql)
 Runs a SELECT and returns every row as name/value maps.
 
std::string queryJson (const std::string &sql)
 Runs query() and serializes the rows to a JSON array.
 
int insert (const std::string &table, const Row &values)
 Inserts a row map; returns the affected row count.
 
int update (const std::string &table, const Row &values, const std::string &whereClause)
 Updates rows matching whereClause; returns the affected row count.
 
int remove (const std::string &table, const std::string &whereClause)
 Deletes rows matching whereClause; returns the affected row count.
 
int insertJson (const std::string &table, const std::string &json)
 Script-friendly insert: JSON must be an object of column/value pairs.
 
int updateJson (const std::string &table, const std::string &json, const std::string &whereClause)
 Script-friendly update; whereClause is raw SQL.
 
int updateByKey (const std::string &table, const Row &values, const std::string &key, const Value &id)
 Updates a single row by primary key value.
 
int removeByKey (const std::string &table, const std::string &key, const Value &id)
 Deletes a single row by primary key value.
 
std::vector< Row > queryByKey (const std::string &table, const std::string &key, const Value &id)
 Selects rows where key == id.
 
Model * model (std::string table, std::string primaryKey="id")
 Builds a script-facing Model repository for a table.
 
Query * from (std::string table)
 Builds a fluent Query builder for a table.
 
template<class T >
int save (const Mapping< T > &mapping, const T &object)
 ORM helper: persists one mapped object.
 
template<class Range , class Mapper >
int exportECS (const std::string &table, const Range &entities, Mapper mapper)
 ORM helper: persists a range of mapped entities in one transaction.
 

详细描述

SQLite connection with a small ORM layer on top of Poco::Data. Tables/columns are quoted identifiers; values are bound as literals.

在文件 Database.h 第 70 行定义.

构造及析构函数说明

◆ Connection() [1/2]

eve::database::Connection::Connection ( std::string  connector,
std::string  connectionString 
)

Opens a Poco::Data session; connector is e.g. "SQLite".

在文件 Database.cpp 第 87 行定义.

◆ ~Connection()

eve::database::Connection::~Connection ( )

Connection.

在文件 Database.cpp 第 92 行定义.

引用了 close().

◆ Connection() [2/2]

eve::database::Connection::Connection ( const Connection &  )
delete

成员函数说明

◆ close()

void eve::database::Connection::close ( )

Closes the session (idempotent).

在文件 Database.cpp 第 94 行定义.

被这些函数引用 ~Connection().

◆ execute()

int eve::database::Connection::execute ( const std::string &  sql)

Executes a statement; returns the affected row count.

在文件 Database.cpp 第 98 行定义.

引用了 execute() , 以及 isConnected().

被这些函数引用 eve::database::Repository< T >::createTable(), execute(), insert(), remove() , 以及 update().

◆ exportECS()

template<class Range , class Mapper >
int eve::database::Connection::exportECS ( const std::string &  table,
const Range &  entities,
Mapper  mapper 
)
inline

ORM helper: persists a range of mapped entities in one transaction.

Export ecs.

Execute.

Execute.

Execute.

在文件 Database.h 第 124 行定义.

引用了 count , 以及 entities.

◆ from()

Query * eve::database::Connection::from ( std::string  table)

Builds a fluent Query builder for a table.

在文件 Database.cpp 第 173 行定义.

◆ insert()

int eve::database::Connection::insert ( const std::string &  table,
const Row &  values 
)

Inserts a row map; returns the affected row count.

在文件 Database.cpp 第 121 行定义.

引用了 columns, execute(), key, literal, value , 以及 values.

被这些函数引用 eve::database::Repository< T >::insert() , 以及 insertJson().

◆ insertJson()

int eve::database::Connection::insertJson ( const std::string &  table,
const std::string &  json 
)

Script-friendly insert: JSON must be an object of column/value pairs.

在文件 Database.cpp 第 150 行定义.

引用了 insert().

被这些函数引用 eve::database::Model::insertJson().

◆ isConnected()

bool eve::database::Connection::isConnected ( ) const

True while the underlying session is open.

在文件 Database.cpp 第 93 行定义.

被这些函数引用 execute() , 以及 query().

◆ model()

Model * eve::database::Connection::model ( std::string  table,
std::string  primaryKey = "id" 
)

Builds a script-facing Model repository for a table.

在文件 Database.cpp 第 170 行定义.

◆ operator=()

Connection & eve::database::Connection::operator= ( const Connection &  )
delete

◆ query()

std::vector< Row > eve::database::Connection::query ( const std::string &  sql)

Runs a SELECT and returns every row as name/value maps.

在文件 Database.cpp 第 103 行定义.

引用了 column , 以及 isConnected().

被这些函数引用 eve::database::Query::all(), eve::database::Repository< T >::all(), eve::database::Query::count(), eve::database::Query::firstJson(), queryByKey() , 以及 queryJson().

◆ queryByKey()

std::vector< Row > eve::database::Connection::queryByKey ( const std::string &  table,
const std::string &  key,
const Value &  id 
)

Selects rows where key == id.

在文件 Database.cpp 第 165 行定义.

引用了 key, literal , 以及 query().

被这些函数引用 eve::database::Repository< T >::find() , 以及 eve::database::Model::findJson().

◆ queryJson()

std::string eve::database::Connection::queryJson ( const std::string &  sql)

Runs query() and serializes the rows to a JSON array.

在文件 Database.cpp 第 119 行定义.

引用了 query().

被这些函数引用 eve::database::Model::allJson().

◆ remove()

int eve::database::Connection::remove ( const std::string &  table,
const std::string &  whereClause 
)

Deletes rows matching whereClause; returns the affected row count.

在文件 Database.cpp 第 146 行定义.

引用了 execute().

被这些函数引用 removeByKey().

◆ removeByKey()

int eve::database::Connection::removeByKey ( const std::string &  table,
const std::string &  key,
const Value &  id 
)

Deletes a single row by primary key value.

在文件 Database.cpp 第 161 行定义.

引用了 key, literal , 以及 remove().

被这些函数引用 eve::database::Model::remove() , 以及 eve::database::Repository< T >::remove().

◆ save()

template<class T >
int eve::database::Connection::save ( const Mapping< T > &  mapping,
const T &  object 
)
inline

ORM helper: persists one mapped object.

Saves save.

Inserts insert.

在文件 Database.h 第 116 行定义.

引用了 eve::database::Mapping< T >::table , 以及 eve::database::Mapping< T >::toRow().

◆ update()

int eve::database::Connection::update ( const std::string &  table,
const Row &  values,
const std::string &  whereClause 
)

Updates rows matching whereClause; returns the affected row count.

在文件 Database.cpp 第 135 行定义.

引用了 execute(), key, literal, value , 以及 values.

被这些函数引用 updateByKey() , 以及 updateJson().

◆ updateByKey()

int eve::database::Connection::updateByKey ( const std::string &  table,
const Row &  values,
const std::string &  key,
const Value &  id 
)

Updates a single row by primary key value.

在文件 Database.cpp 第 157 行定义.

引用了 key, literal, update() , 以及 values.

被这些函数引用 eve::database::Repository< T >::update() , 以及 eve::database::Model::updateJson().

◆ updateJson()

int eve::database::Connection::updateJson ( const std::string &  table,
const std::string &  json,
const std::string &  whereClause 
)

Script-friendly update; whereClause is raw SQL.

在文件 Database.cpp 第 153 行定义.

引用了 update().


该类的文档由以下文件生成: