renamed schema to repository

This commit is contained in:
Sascha Kühl
2025-08-28 16:12:26 +02:00
parent cce7f2c099
commit 3ae2b003aa
45 changed files with 823 additions and 823 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
#include "matador/query/condition.hpp"
#include "matador/object/object_ptr.hpp"
#include "matador/object/schema.hpp"
#include "matador/object/repository.hpp"
#include "matador/utils/access.hpp"
#include "matador/utils/default_type_traits.hpp"
@@ -161,7 +161,7 @@ int main() {
const std::string env_var{"MATADOR_BACKENDS_PATH"};
std::string dns{"sqlite://demo.db"};
schema s( "main" );
repository s( "main" );
auto result = s.attach<author>( "authors" ).and_then( [&s] {
return s.attach<book>( "books" );
} );
+36 -36
View File
@@ -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);
}
}
+5 -5
View File
@@ -17,7 +17,7 @@
#include "work/jobs/IdListPayload.hpp"
#include "matador/utils/default_type_traits.hpp"
#include "matador/object/schema.hpp"
#include "matador/object/repository.hpp"
#include "matador/sql/connection.hpp"
@@ -76,11 +76,11 @@ int main() {
// sql::connection_pool<sql::connection> pool("postgres://news:news@127.0.0.1:15432/matador", 4);
sql::connection_pool pool("postgres://test:test123!@127.0.0.1:5432/matador", 4);
object::schema admin_schema("Administration");
object::repository repo("Administration");
auto result = admin_schema.attach<admin::CollectionCenter>("collection_centers");
admin_schema.create(pool);
admin_schema.drop(pool);
auto result = repo.attach<admin::CollectionCenter>("collection_centers");
repo.create(pool);
repo.drop(pool);
orm::session ses(pool);