added support for UPDATE, INSERT and REMOVE for lists childs

(need some testing)




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1214 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2019-09-24 11:09:11 +00:00
parent a5d5a81a57
commit cff4c1518e
3 changed files with 108 additions and 45 deletions

View File

@@ -69,8 +69,10 @@ public:
std::wstring email;
Language language;
std::list<Attachment> attachments;
Attachment attachment;
void map_fields()
{
field(L"id", id, false, false, true);
@@ -81,7 +83,9 @@ public:
field(L"email", email);
field(L"language_id", L"language", language);
field(L"person_id", L"attachment", attachment, true, true, false);
field(L"person_id", L"attachments", attachments);
//field(L"person_id", L"attachment", attachment, true, true, false);
//field(L"person_id", attachment, f::insertable | f::updatable | f::foreign_key);
//field(L"person_id", attachment, f::insertable, f::updatable, f::foreign_key);
}
@@ -92,6 +96,12 @@ public:
stream << "public.person";
}
void after_select()
{
morm::Finder<Attachment> finder(model_connector);
attachments = finder.select().where().eq(L"person_id", id).get_list();
}
void after_insert()
{
get_last_sequence(L"public.person_id_seq", id);

View File

@@ -65,6 +65,8 @@ void make()
morm::Finder<Person> finder(model_connector);
//std::list<Person> plist = finder.use_table_prefix(false).select().where().eq(L"id", 120).get_list();
Person p = finder.use_table_prefix(false).select().where().eq(L"id", 120).get();
// Person p = finder.prepare_to_select().use_table_prefix(true).raw("select person.id as \"person.id\", person.first_name as \"person.first_name\", person.last_name as \"person.last_name\", person.email as \"person.email\", "
@@ -77,8 +79,21 @@ void make()
// "LEFT JOIN public.language AS language2 ON attachment.language_id = language2.id "
// "where person.id=120").get();
std::cout << "--------------------------------" << std::endl;
p.remove();
std::cout << "--------------------------------" << std::endl;
std::string str;
//str += "--------\n";
p.to_text(str, true, true);
// for(Person & person : plist)
// {
// person.to_text(str, false, true);
// str += "\n--------\n";
// }
std::cout << str << std::endl;
}