[odb-users] Best Practice deleting persistent objects

Steven Côté steven.cote at gmail.com
Thu Apr 3 11:26:17 EDT 2014


>
> Solution 0 limits the number of groups a user can be in to at most 1.
>
> Perhaps the first issue is to determine if a user shall be able to be
> in 1 or more groups? :)
>

It is true. In this particular case, a user can be in 0 to * groups. So
option 0 as written won't work for me. Judging by the rest of the answers,
it sounds like the real answer is to link the group back to the user. So in
my case it would be something like:

class group;

#pragma db object
class user
{
   ...

   std::vector<group*> belongs;
};

#pragma db object
class group
{
     ...

     #pragma db inverse(belongs)
     std::vector<user*> member;
};

Is it possible to describe a relationship like that in the pragma language?
I'll have a flip through the manual in the morning to see if there's any
mention of that. Otherwise I guess I'm waiting for version 2.4.0.


More information about the odb-users mailing list