You are not logged in.
Pages: 1
Probably it is stupid but as I am doing my first moves using Mormot2 I have not find a sure way to deal with the following:
I have the following entities:
TOrmProductSource = class(TOrm)
private
Fmoo:rawutf8;
Fopa:TOrmProductDest;
Fcount:PtrInt;
published
property moo:rawutf8 read Fmoo write Fmoo;
property opa:TOrmProductDest read Fopa write Fopa;
property count:PtrInt read Fcount write Fcount;
end;
TOrmProductDest = class(TOrm)
private
Ftest:RawUtf8;
Famount:PtrInt;
published
property test:RawUtf8 read Ftest write Ftest;
property amount:PtrInt read Famount write Famount;
end;
The TOrmProductDest is used by other Torms also and can not be an integrated collection in TOrmProductSource.
I want to retrieve all TOrmProductSource that have a count property of less than 10 and the opa's amount property with a value of more than 50.
How can I combine these two or more Torms in one request?
Thank you in advance
Last edited by dcoun (2022-01-25 08:51:20)
Offline
The mORMot 1 documentation still work on this subject.
Just replace TSQLRecord* into TOrm* names.
Offline
The mORMot 1 documentation still work on this subject.
Just replace TSQLRecord* into TOrm* names.
I am a bit lost reading about many2many associations with a separate Torm that holds many to many information.
I have already tables that they are mapped to TOrms and have pointers to other TOrms tables.
Is there a way to use an 'one to many' relationship with the included pointer (Fopa:TOrmProductDest)?
I do not need something complicated. Each Torm has max 2 pointers to other Torms
Last edited by dcoun (2022-01-25 09:04:58)
Offline
Only the TOrmMany class has the methods to handle joins.
You can just inherit the ORM class which maps the pivot table from TOrmMany instead of plain TOrm.
Understood. not possible without a pivot table. I have to stay with sql queries then. Thanks a lot.
Offline
Pages: 1