A very nice opportunity to exhibit the powers of SORM.
As indicated in the Features of SORM, it abstracts away from ALL relational concepts. This includes foreign keys.
The foreign key abstraction is provided by natural direct references to these entities you wanted to refer to with a foreign key. So instead of userId
pointing to the id
of User
, you should point to the User
itself with the user
property:
case class User(login: String, firstName: String, lastName: String)
case class UserSite(user: User, name: String, url: String)
Under the hood this will translate exactly into what you wanted to achieve with the Foreign Key. But the thing is you don't have to care about it.
A sidenote. When working with SORM you should design your model the way you want to use it in Scala with almost no limitations, and you should definitely throw all the relational concepts you got used to when designing models out of your mind. That's the way of SORM.
Concerning the documentation and library structure. The approach is very simple: if it's not documented, it is not intended to be used as part of public API. Also with the current (v. 0.3.x
) structure of SORM all components of the public API reside in the sorm._
package, so another rule is if it's not there it is not intended for public API.