[odb-users] object view query
MM
finjulhich at gmail.com
Fri Jun 22 15:29:30 EDT 2018
Hello,
I am struggling to express a query that will load my objects where the
condition depends on non direct relationships on another specified object.
struct MyGroup {
std::vector<Period> periods;
int id;
};
#pragma db object(MyGroup)
struct Period {
MyObjectContainer* c;
...
};
#pragma db value(Period) definition
#pragma db member(Period::c) transient
#pragma db member(Period::cid) virtual(int) ...
struct MyObjectContainer {
int id;
...
};
#pragma db object(MyObjectContainer) definition
struct MyObject {
int id;
MyObjectContainer* mycontainer;
};
#pragma db object(MyObject) definition
#pragma db member(MyObject::containerid) virtual(int) ...
I am given a MyGroup id, and I need to load all the MyObjects such that
their "mycontainer" is referred to by 1 of the Periods in the given MyGroup.
I know how to write the direct SELECT query for that but I'd rather load
MyGroup via a db.query call.
Perhaps I don't even need a view and I can express this as a regular
db.query<MyObject>( .... )
MM
More information about the odb-users
mailing list