renamed schema to repository
This commit is contained in:
+36
-36
@@ -1,4 +1,4 @@
|
||||
#include "matador/object/schema.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
|
||||
#include "matador/logger/log_manager.hpp"
|
||||
|
||||
@@ -133,82 +133,82 @@ int main() {
|
||||
|
||||
{
|
||||
// has_many with builtin-type
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<names>("names");
|
||||
auto result = repo.attach<names>("names");
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many with foreign without belongs_to
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<person_repo>("person_repo")
|
||||
.and_then([&schema] { return schema.attach<person>("persons"); });
|
||||
auto result = repo.attach<person_repo>("person_repo")
|
||||
.and_then([&repo] { return repo.attach<person>("persons"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many with foreign without belongs_to
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<person>("persons")
|
||||
.and_then([&schema] { return schema.attach<person_repo>("person_repo"); });
|
||||
auto result = repo.attach<person>("persons")
|
||||
.and_then([&repo] { return repo.attach<person_repo>("person_repo"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many to belongs_to
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<author>("authors")
|
||||
.and_then([&schema] { return schema.attach<book>("books"); });
|
||||
auto result = repo.attach<author>("authors")
|
||||
.and_then([&repo] { return repo.attach<book>("books"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// belongs_to to has_many
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<book>("books")
|
||||
.and_then([&schema] { return schema.attach<author>("authors"); });
|
||||
auto result = repo.attach<book>("books")
|
||||
.and_then([&repo] { return repo.attach<author>("authors"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many_to_many (with join columns first)
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<demo::ingredient>("ingredients")
|
||||
.and_then([&schema] { return schema.attach<recipe>("recipes"); });
|
||||
auto result = repo.attach<demo::ingredient>("ingredients")
|
||||
.and_then([&repo] { return repo.attach<recipe>("recipes"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_many_to_many (with join columns last)
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<demo::recipe>("recipes")
|
||||
.and_then([&schema] { return schema.attach<ingredient>("ingredients"); });
|
||||
auto result = repo.attach<demo::recipe>("recipes")
|
||||
.and_then([&repo] { return repo.attach<ingredient>("ingredients"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// belongs_to to has_one
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<profile>("profiles")
|
||||
.and_then([&schema] { return schema.attach<user>("users"); });
|
||||
auto result = repo.attach<profile>("profiles")
|
||||
.and_then([&repo] { return repo.attach<user>("users"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
{
|
||||
// has_one to belongs_to
|
||||
object::schema schema;
|
||||
object::repository repo;
|
||||
|
||||
auto result = schema.attach<user>("users")
|
||||
.and_then([&schema] { return schema.attach<profile>("profiles"); });
|
||||
auto result = repo.attach<user>("users")
|
||||
.and_then([&repo] { return repo.attach<profile>("profiles"); });
|
||||
|
||||
schema.dump(std::cout);
|
||||
repo.dump(std::cout);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user