Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61a80d93f7 | ||
|
|
98af2bc6c4 | ||
|
|
405f158a88 |
+6
-3
@@ -156,16 +156,19 @@ QUERY_HELPER( temporary_table, id );
|
||||
int main() {
|
||||
using namespace matador::sql;
|
||||
using namespace matador::object;
|
||||
using namespace matador::utils;
|
||||
|
||||
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
||||
|
||||
std::string dns{"sqlite://demo.db"};
|
||||
schema s( "main" );
|
||||
s.attach<author>( "authors" );
|
||||
s.attach<book>( "books" );
|
||||
auto result = s.attach<author>( "authors" ).and_then( [&s] {
|
||||
return s.attach<book>( "books" );
|
||||
} );
|
||||
// s.attach<book>( "books" );
|
||||
|
||||
connection c( dns );
|
||||
auto result = c.open();
|
||||
result = c.open();
|
||||
// s.create( c );
|
||||
//
|
||||
// auto create_authors_sql = c.query( s )
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
explicit schema( const std::string& name = "");
|
||||
|
||||
template <typename Type>
|
||||
utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
||||
[[nodiscard]] utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
||||
auto node = schema_node::make_node<Type>(*this, name);
|
||||
|
||||
auto result = attach_node(node, parent);
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename Type, typename ParentType>
|
||||
utils::result<void, utils::error> attach(const std::string name) {
|
||||
[[nodiscard]] utils::result<void, utils::error> attach(const std::string name) {
|
||||
auto node = schema_node::make_node<Type>(*this, name);
|
||||
|
||||
auto result = attach_node(node, std::type_index(typeid(ParentType)));
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
[[nodiscard]] bool is_ok() const { return !result_.has_value(); }
|
||||
[[nodiscard]] bool is_error() const { return result_.has_value(); }
|
||||
|
||||
ErrorType&& release_error() { return result_->release(); }
|
||||
ErrorType&& release_error() { return std::move(*result_); }
|
||||
|
||||
const ErrorType& err() const { return result_.value(); }
|
||||
ErrorType err() { return result_.value(); }
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
return result<SecondValueType, ErrorType>(ok(f()));
|
||||
}
|
||||
|
||||
return result<SecondValueType, ErrorType>(error(release_error()));
|
||||
return result<SecondValueType, ErrorType>(failure(release_error()));
|
||||
}
|
||||
|
||||
template<typename Func>
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
return f();
|
||||
}
|
||||
|
||||
return result(error(release_error()));
|
||||
return result(failure(release_error()));
|
||||
}
|
||||
|
||||
template<typename Func, typename SecondErrorType = typename std::invoke_result_t<Func, ErrorType >::value_type>
|
||||
|
||||
Reference in New Issue
Block a user