Saturday 15 September 2012

scala - Multiple Left Joins in squeryl -


My data model contains users that a user can have multiple folders and one folder can have multiple accounts.

I run a query that gives all the above information in one go.

To return users, this looks like with the query folder:

  val usersWithFolder = (MySchema.users, MySchema.folders) ((U, F) = & Gt; Select (u.idField === f.userId) ((U, F)))   

And I want a query like this: < Pre> join (MySchema.users, MySchema.folders.leftOuter, MySkyma.Credit.BoundOper) ((U, F, A) => (U, F, A) at (U.Iffield === FMAP (_UserID), ???))

How do I map accounts to folders? I can not use the f.idField === a.map (_ folderId) because it looks like f is list .

I think that f a Option will be , so something like this should be done:

  join (MySchema.users, MySchema.folders.leftOuter, MySchema .accounts.leftOuter) ((U, F, A) = & Gt; Select (U, F, A) at (U.IDField === FMAP (_UserID), FMAP (_IDIDFIELD) = == a.map (_ folderId))    

No comments:

Post a Comment