Compare commits
No commits in common. "61a80d93f72c4cac30df2e2ca6cfcf185ddbd9f2" and "f01e9ff87f1b88066f6b56acacb22cb3355c7d46" have entirely different histories.
61a80d93f7
...
f01e9ff87f
|
|
@ -156,19 +156,16 @@ QUERY_HELPER( temporary_table, id );
|
||||||
int main() {
|
int main() {
|
||||||
using namespace matador::sql;
|
using namespace matador::sql;
|
||||||
using namespace matador::object;
|
using namespace matador::object;
|
||||||
using namespace matador::utils;
|
|
||||||
|
|
||||||
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
||||||
|
|
||||||
std::string dns{"sqlite://demo.db"};
|
std::string dns{"sqlite://demo.db"};
|
||||||
schema s( "main" );
|
schema s( "main" );
|
||||||
auto result = s.attach<author>( "authors" ).and_then( [&s] {
|
s.attach<author>( "authors" );
|
||||||
return s.attach<book>( "books" );
|
s.attach<book>( "books" );
|
||||||
} );
|
|
||||||
// s.attach<book>( "books" );
|
|
||||||
|
|
||||||
connection c( dns );
|
connection c( dns );
|
||||||
result = c.open();
|
auto result = c.open();
|
||||||
// s.create( c );
|
// s.create( c );
|
||||||
//
|
//
|
||||||
// auto create_authors_sql = c.query( s )
|
// auto create_authors_sql = c.query( s )
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
explicit schema( const std::string& name = "");
|
explicit schema( const std::string& name = "");
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
[[nodiscard]] utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
||||||
auto node = schema_node::make_node<Type>(*this, name);
|
auto node = schema_node::make_node<Type>(*this, name);
|
||||||
|
|
||||||
auto result = attach_node(node, parent);
|
auto result = attach_node(node, parent);
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type, typename ParentType>
|
template <typename Type, typename ParentType>
|
||||||
[[nodiscard]] utils::result<void, utils::error> attach(const std::string name) {
|
utils::result<void, utils::error> attach(const std::string name) {
|
||||||
auto node = schema_node::make_node<Type>(*this, name);
|
auto node = schema_node::make_node<Type>(*this, name);
|
||||||
|
|
||||||
auto result = attach_node(node, std::type_index(typeid(ParentType)));
|
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_ok() const { return !result_.has_value(); }
|
||||||
[[nodiscard]] bool is_error() const { return result_.has_value(); }
|
[[nodiscard]] bool is_error() const { return result_.has_value(); }
|
||||||
|
|
||||||
ErrorType&& release_error() { return std::move(*result_); }
|
ErrorType&& release_error() { return result_->release(); }
|
||||||
|
|
||||||
const ErrorType& err() const { return result_.value(); }
|
const ErrorType& err() const { return result_.value(); }
|
||||||
ErrorType err() { return result_.value(); }
|
ErrorType err() { return result_.value(); }
|
||||||
|
|
@ -167,7 +167,7 @@ public:
|
||||||
return result<SecondValueType, ErrorType>(ok(f()));
|
return result<SecondValueType, ErrorType>(ok(f()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result<SecondValueType, ErrorType>(failure(release_error()));
|
return result<SecondValueType, ErrorType>(error(release_error()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
|
|
@ -176,7 +176,7 @@ public:
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result(failure(release_error()));
|
return result(error(release_error()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Func, typename SecondErrorType = typename std::invoke_result_t<Func, ErrorType >::value_type>
|
template<typename Func, typename SecondErrorType = typename std::invoke_result_t<Func, ErrorType >::value_type>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue