Providing SELECT, INSERT, UPDATE, DELETE or raw queries for SQLiteDatabase.
More...
#include <SQLiteDatabaseModel.h>
|
| SQLiteDatabaseModel (const SQLiteDatabaseModel &)=delete |
|
SQLiteDatabaseModel & | operator= (const SQLiteDatabaseModel &)=delete |
|
| SQLiteDatabaseModel (SQLiteDatabaseModel &&other) noexcept=default |
|
SQLiteDatabaseModel & | operator= (SQLiteDatabaseModel &&other) noexcept=default |
|
utility::SQLiteResult | raw (const std::string &query) |
| Raw SQL query.
|
|
virtual void | createTable (const std::vector< std::pair< std::string, std::string > > &attributes={}) |
| Create table.
|
|
virtual void | dropTable () |
| Delete table.
|
|
virtual void | recreateTable (const std::vector< std::pair< std::string, std::string > > &attributes={}) |
| Delete and create table.
|
|
virtual utility::SQLiteResult | insert (const std::unordered_map< std::string, std::string > &attributes={}) |
| INSERT row.
|
|
virtual void | update (const std::unordered_map< std::string, std::string > &attributes, const std::string &fieldName, const std::string &fieldValue) |
| UPDATE table.
|
|
virtual void | deleteQuery (const std::string &fieldName, const std::string &fieldValue) |
| Delete from table.
|
|
virtual void | deleteQuery (const std::unordered_map< std::string, std::string > &attributes={}) |
| Delete from table.
|
|
utility::SQLiteResult | selectAll () |
| SELECT all.
|
|
virtual utility::SQLiteResult | selectByField (const std::string &fieldName, const std::string &fieldValue) |
| SELECT with condition.
|
|
virtual utility::SQLiteResult | selectByField (const std::unordered_map< std::string, std::string > &attributes) |
| SELECT with condition.
|
|
virtual std::string_view | getDatabaseName () const =0 |
|
virtual std::string_view | getTableName () const =0 |
|
|
static bool | isNumber (std::string_view source) |
| Check that string represent number.
|
|
static std::string | convertToValue (std::string_view source) |
| If source is string surrounds it with quotes.
|
|
Providing SELECT, INSERT, UPDATE, DELETE or raw queries for SQLiteDatabase.
Definition at line 20 of file SQLiteDatabaseModel.h.
◆ SQLiteDatabaseModel()
framework::sqlite::SQLiteDatabaseModel::SQLiteDatabaseModel |
( |
| ) |
|
◆ convertToValue()
string framework::sqlite::SQLiteDatabaseModel::convertToValue |
( |
std::string_view | source | ) |
|
|
staticprotected |
◆ createTable()
void framework::sqlite::SQLiteDatabaseModel::createTable |
( |
const std::vector< std::pair< std::string, std::string > > & | attributes = {} | ) |
|
|
virtual |
Create table.
- Parameters
-
attributes | field name - field description |
- Exceptions
-
Definition at line 92 of file SQLiteDatabaseModel.cpp.
◆ deleteQuery() [1/2]
virtual void framework::sqlite::SQLiteDatabaseModel::deleteQuery |
( |
const std::string & | fieldName, |
|
|
const std::string & | fieldValue ) |
|
virtual |
Delete from table.
- Parameters
-
fieldName | for condition |
fieldValue | for condition |
- Exceptions
-
◆ deleteQuery() [2/2]
virtual void framework::sqlite::SQLiteDatabaseModel::deleteQuery |
( |
const std::unordered_map< std::string, std::string > & | attributes = {} | ) |
|
|
virtual |
Delete from table.
- Parameters
-
attributes | key - value condition |
- Exceptions
-
◆ dropTable()
void framework::sqlite::SQLiteDatabaseModel::dropTable |
( |
| ) |
|
|
virtual |
◆ execute()
◆ insert()
utility::SQLiteResult framework::sqlite::SQLiteDatabaseModel::insert |
( |
const std::unordered_map< std::string, std::string > & | attributes = {} | ) |
|
|
virtual |
◆ isNumber()
bool framework::sqlite::SQLiteDatabaseModel::isNumber |
( |
std::string_view | source | ) |
|
|
staticprotected |
Check that string represent number.
- Parameters
-
- Returns
- true if source is correct number, false otherwise
Definition at line 11 of file SQLiteDatabaseModel.cpp.
◆ raw()
Raw SQL query.
- Parameters
-
- Returns
- result of SELECT query, empty string otherwise
- Exceptions
-
Definition at line 87 of file SQLiteDatabaseModel.cpp.
◆ recreateTable()
void framework::sqlite::SQLiteDatabaseModel::recreateTable |
( |
const std::vector< std::pair< std::string, std::string > > & | attributes = {} | ) |
|
|
virtual |
Delete and create table.
- Parameters
-
attributes | field name- field description |
- Exceptions
-
Definition at line 111 of file SQLiteDatabaseModel.cpp.
◆ selectAll()
◆ selectByField() [1/2]
virtual utility::SQLiteResult framework::sqlite::SQLiteDatabaseModel::selectByField |
( |
const std::string & | fieldName, |
|
|
const std::string & | fieldValue ) |
|
virtual |
SELECT with condition.
- Parameters
-
fieldName | for condition |
fieldValue | for condition |
- Returns
- all rows that accept condition
- Exceptions
-
◆ selectByField() [2/2]
virtual utility::SQLiteResult framework::sqlite::SQLiteDatabaseModel::selectByField |
( |
const std::unordered_map< std::string, std::string > & | attributes | ) |
|
|
virtual |
SELECT with condition.
- Parameters
-
values | field name - field value |
- Returns
- all rows that accept condition
- Exceptions
-
◆ update()
void framework::sqlite::SQLiteDatabaseModel::update |
( |
const std::unordered_map< std::string, std::string > & | attributes, |
|
|
const std::string & | fieldName, |
|
|
const std::string & | fieldValue ) |
|
virtual |
UPDATE table.
- Parameters
-
attributes | new values |
fieldName | for condition |
fieldValue | for condition |
- Exceptions
-
Definition at line 132 of file SQLiteDatabaseModel.cpp.
◆ SQLiteManager
◆ database
std::shared_ptr<SQLiteDatabase> framework::sqlite::SQLiteDatabaseModel::database |
|
protected |
◆ databaseName
std::string_view framework::sqlite::SQLiteDatabaseModel::databaseName = "" |
|
staticconstexpr |
◆ tableName
std::string_view framework::sqlite::SQLiteDatabaseModel::tableName = "" |
|
staticconstexpr |
The documentation for this class was generated from the following files: