schema progress
This commit is contained in:
+13
-13
@@ -62,9 +62,9 @@ int main()
|
||||
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
||||
|
||||
std::string dns{"sqlite://demo.db"};
|
||||
auto s = std::make_shared<schema>("main");
|
||||
s->attach<author>("authors");
|
||||
s->attach<book>("books");
|
||||
schema s("main");
|
||||
s.attach<author>("authors");
|
||||
s.attach<book>("books");
|
||||
|
||||
connection c(dns);
|
||||
c.open();
|
||||
@@ -81,17 +81,17 @@ int main()
|
||||
|
||||
std::cout << "SQL: " << create_authors_sql << "\n";
|
||||
|
||||
auto mc = make_entity<author>();
|
||||
mc->id = 1;
|
||||
mc->first_name = "Michael";
|
||||
mc->last_name = "Crichton";
|
||||
mc->date_of_birth = "19.8.1954";
|
||||
mc->year_of_birth = 1954;
|
||||
mc->distinguished = true;
|
||||
author mc;
|
||||
mc.id = 1;
|
||||
mc.first_name = "Michael";
|
||||
mc.last_name = "Crichton";
|
||||
mc.date_of_birth = "19.8.1954";
|
||||
mc.year_of_birth = 1954;
|
||||
mc.distinguished = true;
|
||||
auto insert_authors_sql = c.query(s)
|
||||
.insert()
|
||||
.into<author>(qh::authors)
|
||||
.values(*mc)
|
||||
.values(mc)
|
||||
.execute();
|
||||
|
||||
std::cout << "SQL: " << insert_authors_sql << "\n";
|
||||
@@ -126,13 +126,13 @@ int main()
|
||||
c.query(s)
|
||||
.insert()
|
||||
.into<book>(qh::books)
|
||||
.values({2, "It", mc->id, 1980})
|
||||
.values({2, "It", mc.id, 1980})
|
||||
.execute();
|
||||
|
||||
c.query(s)
|
||||
.insert()
|
||||
.into<book>(qh::books)
|
||||
.values({3, "Misery", mc->id, 1984})
|
||||
.values({3, "Misery", mc.id, 1984})
|
||||
.execute();
|
||||
|
||||
auto select_books_sql = c.query(s)
|
||||
|
||||
Reference in New Issue
Block a user