The tef::Database
and tef::Db<
classes provide an unified SQL-like interface (WebSQL) to both relational and non-relational (NoSQL) databases.
class
FetchBuffer>
|
name : specifies a configured database connection.See Database connections. |
|
Builds a SQL string. |
template<typename
|
Binds a fetch buffer. |
bool
void void void
|
Provides the transaction support. |
template<typename void int bool
|
Executes the SQL. |
void
|
Throws an exception in case of an error. |
void void
|
Writes custom attributes specific to the database driver: HTTP request headers, etc. Note: custom attributes must be written before the SQL string. Every HTTP header must end with "\r\n". See the example bellow. |
const wchar_t* int
|
Reads custom attributes specific to the database driver: HTTP response headers, etc.
Note: the returned pointer is valid within lifetime of the tef::Database instance.
See the example bellow.
|
tef::Database db(L"ms"); db << L"insert ROOT (UID, USR) values (" << uid << L",'" << usr << L"')"; db.Execute();
struct Record { tef::db::type<__int64> uid; tef::db::type<wchar_t, 30> usr; }; tef::Db<Record> db(L"ms"); db << L"select UID, USR from ROOT"; db >> db->uid >> db->usr; while( db.Fetch() ) { printf_s("%I64d", db->uid.value); }
tef::Database db(L"doc"); db.BeginAttributes(); db << "If-Match: \"" << _etag << "\"\r\n"; db.EndAttributes(); db << "replace ROOT { \"UID\": " << uid << ", \"USR\": \"" << usr << "\"}"; db.ExecuteAsync([](tef::Database& db) { try { db.ThrowIfError(); int charge = db.ResponseAttributeInt32(L"x-ms-request-charge"); } catch(std::exception& e) { } });
tef::Db<tef::db::json> db(L"doc"); db << "select * from ROOT"; db.ExecuteAsync([](tef::Db<tef::db::json>& db) { try { while( db.Fetch() ) { printf_s("%I64d", db["UID"]); } } catch(std::exception& e) { } });