added any type visitor and converter
This commit is contained in:
@@ -1,3 +1,45 @@
|
||||
# query
|
||||
|
||||
A fluent sql query builder
|
||||
A fluent sql query builder
|
||||
|
||||
Object definition
|
||||
```cpp
|
||||
struct airplane
|
||||
{
|
||||
unsigned long id;
|
||||
std::string brand;
|
||||
std::string model;
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::utils::access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "brand", brand, 255);
|
||||
field::attribute(op, "model", model, 255);
|
||||
}
|
||||
};
|
||||
```
|
||||
```cpp
|
||||
connection_pool<connection> pool("sqlite://sqlite.db", 4);
|
||||
session s(pool);
|
||||
|
||||
// register entity
|
||||
s.attach<airplane>("airplane")
|
||||
|
||||
// create all tables
|
||||
s.create();
|
||||
|
||||
// insert
|
||||
s.insert<airplane>(1, "Airbus", "A380");
|
||||
s.insert<airplane>(2, "Boeing", "748");
|
||||
s.insert<airplane>(3, "Boeing", "707");
|
||||
|
||||
s.update<airplane>().set({"model", "747"}).where("id"_col == 2);
|
||||
|
||||
auto result = s.select<airplane>().where("brand"_col == "Boeing");
|
||||
|
||||
for (const auto &plane : result) {
|
||||
std::cout << "airplane: " << plane->brand << " - " << plane->model << "\n";
|
||||
}
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user