Reputation: 6879
Is it as strait-forward as this? (Please take a look at interestedLinks in User, and usersInterestedInMe in Link.)
case class User(firstName: String, lastName: String, interestedLinks: Set[Link])
case class Link(name: String, url: String, usersInterestedInMe: Set[User])
If not, how do we declare many to many in SORM?
Upvotes: 1
Views: 203
Reputation: 43330
Yes, it would be as straight forward as you described, if only your entities didn't form an infinite recursion, which would bring up multiple problems, but, above all, you wouldn't be able to even create such a value, since it's impossible to do in a strict immutable world. Don't believe me? Just throw SORM out of your head and try to instantiate any of your classes with some reasonable values.
So yeah, I'd say either go with rejecting either of interestedLinks: Set[Link]
or usersInterestedInMe: Set[User]
or model a graph-like relation.
Upvotes: 1