added schema creation to session class
This commit is contained in:
@@ -200,7 +200,8 @@ class query_create_intermediate : public query_start_intermediate
|
||||
public:
|
||||
explicit query_create_intermediate(connection &db);
|
||||
|
||||
query_execute_finish table(const std::string &table, std::initializer_list<column> columns);
|
||||
query_execute_finish table(const std::string &table_name, std::initializer_list<column> columns);
|
||||
query_execute_finish table(const std::string &table_name, const std::vector<column> &columns);
|
||||
template<class Type>
|
||||
query_execute_finish table(const std::string &table_name)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@ public:
|
||||
template<typename Type>
|
||||
void attach(const std::string &table_name);
|
||||
|
||||
void create_schema();
|
||||
|
||||
template<typename Type>
|
||||
entity<Type> insert(Type *obj);
|
||||
|
||||
|
||||
@@ -11,15 +11,23 @@
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
class connection;
|
||||
|
||||
struct table_info
|
||||
{
|
||||
std::string name;
|
||||
record prototype;
|
||||
void create(connection &conn) const;
|
||||
void drop(connection &conn) const;
|
||||
};
|
||||
|
||||
class table_repository
|
||||
{
|
||||
public:
|
||||
using repository = std::unordered_map<std::type_index, table_info>;
|
||||
using iterator = repository::iterator;
|
||||
using const_iterator = repository::const_iterator;
|
||||
|
||||
template<typename Type>
|
||||
const table_info& attach(const std::string &table_name)
|
||||
{
|
||||
@@ -52,8 +60,14 @@ public:
|
||||
|
||||
[[nodiscard]] bool exists(const std::type_index &ti) const;
|
||||
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
private:
|
||||
using repository = std::unordered_map<std::type_index, table_info>;
|
||||
repository repository_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user