Re: many-to-many with attributes?
Re: many-to-many with attributes?
- Subject: Re: many-to-many with attributes?
- From: Zak Burke <email@hidden>
- Date: Tue, 26 Jul 2005 14:39:24 -0400
Jim Zajkowski wrote on 7/26/05 1:34 PM:
> Hi there,
>
> What's the best way to handle a many-to-many relationship that has an
> attribute on the relation?
[...]
> So, what's the best way to do it? Not flatten the relation and walk
> the m-to-m by hand?
Yes. Given something like User <<-- Membership -->> Group, and assuming
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
that ought to be User -->> Membership <<-- Group
you've created relations named "membership" on each of user and group,
and relations named "users" and "groups" on User and Group,
respectively, you can easily traverse the relationships like so on User:
// returns a list of the groups a user is in
public NSArray groups()
{
return (NSArray) membership().valueForKey("groups");
}
zak.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden