query parts progress
This commit is contained in:
+9
-8
@@ -44,17 +44,18 @@ struct book
|
||||
namespace field = matador::utils::access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "title", title, 511);
|
||||
field::has_one(op, "authors", book_author, matador::utils::default_foreign_attributes);
|
||||
field::has_one(op, "author_id", book_author, matador::utils::default_foreign_attributes);
|
||||
field::attribute(op, "published_in", published_in);
|
||||
}
|
||||
};
|
||||
|
||||
QUERY_HELPER(authors, id, first_name, last_name, date_of_birth, year_of_birth, distinguished)
|
||||
QUERY_HELPER(books, id, book_author, title, published_in)
|
||||
QUERY_HELPER(books, id, author_id, title, published_in)
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace matador::sql;
|
||||
using namespace matador;
|
||||
|
||||
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
||||
|
||||
@@ -67,12 +68,12 @@ int main()
|
||||
connection c(dns, s);
|
||||
|
||||
auto books = c.query()
|
||||
.select<book>({matador::qh::books.id.name})
|
||||
.from({"book"})
|
||||
.join_left({"authors"})
|
||||
.on("book.author_id"_col == "author.id"_col)
|
||||
.where("book.published_in"_col < 2008 && "author.name"_col == "Michael Crichton")
|
||||
.order_by("book.title").asc()
|
||||
.select<book>({qh::authors.first_name})
|
||||
.from(qh::books)
|
||||
.join_left(qh::authors)
|
||||
.on(qh::books.author_id == qh::authors.id)
|
||||
.where(qh::books.published_in < 2008 && qh::authors.first_name == "Michael Crichton")
|
||||
.order_by(qh::books.title).asc()
|
||||
.offset(2)
|
||||
.limit(5)
|
||||
.str();
|
||||
|
||||
Reference in New Issue
Block a user