Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Scala Slick查询对象获取表ID信息_Scala_Slick_Sharding_Typesafe - Fatal编程技术网

如何从Scala Slick查询对象获取表ID信息

如何从Scala Slick查询对象获取表ID信息,scala,slick,sharding,typesafe,Scala,Slick,Sharding,Typesafe,如何在运行时从上述查询中获取用户id信息。如果查询更复杂,比如 val users = TableQuery[Users] val query = for( user <- Users.filter(_.id === 1L) ) yield user println(query.toNode.nodeChildNames.toBuffer) gives something like this => ArrayBuffer(from @1276230271, select)

如何在运行时从上述查询中获取用户id信息。如果查询更复杂,比如

val users = TableQuery[Users]

val query = for( user <- Users.filter(_.id === 1L) ) yield user

println(query.toNode.nodeChildNames.toBuffer)

gives something like this  => ArrayBuffer(from @1276230271, select)
通过上面的查询,我们可以使用对查询对象的访问来动态访问每个查询中涉及的表名和主键


谢谢。

您必须生成一个元组post.id、user.id、comment.id,例如:

val query = for( user <- users.filter(_name === "cat")

                 post < posts.filter(_.postedBy === user.id)

                 comment <- comments.filter(_.postId === post.id) ) yield comment

很抱歉我没有清楚地说明问题中的问题。我已经改变了这个问题,现在请考虑重新回答这个问题。谢谢
val query = for{ user <- users.filter(_name === "cat")
                 post <- posts.filter(_.postedBy === user.id)
                 comment <- comments.filter(_.postId === post.id) }
            yield (post.id, user.id, comment.id)

query.list