join - Slick 3.0 Multiple Many-To-Many calls -


taking inspiration post:

how can present many-to-many relationship using link table scalaquery or slick?

my situation same small exception.

def testmanytomany(): unit = db withsession {      object extends table[(int, string)]("a") {       def id = column[int]("id", o.primarykey)       def s = column[string]("s")       def * = id ~ s       def bs = atob.filter(_.aid === id).flatmap(_.bfk)        // note have many-to-many join       def cs = atoc.filter(_cid === id).flatmap(_.afk)     }      object b extends table[(int, string)]("b") {       def id = column[int]("id", o.primarykey)       def s = column[string]("s")       def * = id ~ s       def = atob.filter(_.bid === id).flatmap(_.afk)     }      object atob extends table[(int, int)]("a_to_b") {       def aid = column[int]("a")       def bid = column[int]("b")       def * = aid ~ bid       def afk = foreignkey("a_fk", aid, a)(a => a.id)       def bfk = foreignkey("b_fk", bid, b)(b => b.id)     }      object atoc extends table[(int, int)]("a_to_c") {       def aid = column[int]("a")       def cid = column[int]("c")       def * = aid ~ cid       def afk = foreignkey("a_fk", aid, a)(a => a.id)       def cfk = foreignkey("c_fk", cid, c)(c => c.id)     }   }  when want fetch a's id, want fetch associations in b , c, like:      {       <- if a.id >= 2       atob <- atob if atob.aid === a.id       b <- b if b.id === atob.bid     } yield (a.s, b.s)  how can include join c table? having correct?      {       <- if a.id >= 2       atob <- atob if atob.aid === a.id       atoc <- atoc if atoc.aid === a.id       b <- b if b.id === atob.bid       c <- c if c.id === atoc.cid     } yield (a.s, b.s) 

wouldn't try sub-select on atoc each atob flatmap operation?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -