relation completer progress

This commit is contained in:
2025-07-06 20:06:26 +02:00
parent 5c1e0ae0d8
commit c974628bee
11 changed files with 358 additions and 163 deletions
+30 -10
View File
@@ -5,20 +5,19 @@
#include "author.hpp"
#include "book.hpp"
#include <iostream>
/*
* node author
*
* relation_endpoints
* 1. - field_name "books"
* - type_index <book>
* - type "has_many"
* - node <author>
* - foreign endpoint (1) "author"
*
* node book
* 2. - field_name "author_id"
* - type_index <author>
* - type "belongs_to"
* - node <book>
* - foreign endpoint (2) "books"
@@ -32,29 +31,50 @@
* - create node many_to_many_relation<author, book>("author_id", "id")
* - 3. create endpoint
* - field name "author_id"
* - type_index <author>
* - type "belongs_to"
* - node <many_to_many_relation<author, book>>
* - foreign endpoint (1) "author
* - set foreign endpoint of (1) to endpoint (3)
* - register endpoint in authors node by type book
* - attach (internal) node<many_to_many_relation<author, book>>
*
* attach<book>
* - relation completer detects "belongs_to<author>"
* - belongs_to<author> finds <book>
* - try to find relation endpoint of type book in authors node
* - if endpoint was found
* - validate node in endpoint
* - if node is of type many_to_many_relation
* - detach node of endpoint
* - update node in endpoint to <book>
* - else
* - create endpoint <book> (1)
* - create endpoint <author> (2)
* - set foreign endpoint of (1) to endpoint (2)
* - set foreign endpoint of (2) to endpoint (1)
* - check relation endpoints...
*
*
*
*/
using namespace demo;
using namespace matador;
int main() {
logger::default_min_log_level(logger::log_level::LVL_DEBUG);
logger::add_log_sink(logger::create_stdout_sink());
int main() {
logger::default_min_log_level(logger::log_level::LVL_DEBUG);
logger::add_log_sink(logger::create_stdout_sink());
{
object::schema schema;
auto result = schema.attach<author>("authors")
.and_then([&schema] { return schema.attach<book>("books"); });
}
schema.dump(std::cout);
}
{
object::schema schema;
auto result = schema.attach<book>("books")
.and_then([&schema] { return schema.attach<author>("authors"); });
schema.dump(std::cout);
}
}