using the query dsl
To get started using the query DSL, we will look at a simple example of finding all blog posts for a blog. You simply need to import the query DSL from your persistent type:
import longevity.persistence.PState
import scala.concurrent.Future
val blog: Blog = getBlogFromSomewhere()
import BlogPost.queryDsl._
val allPosts: Future[Vector[PState[BlogPost]]] = repo.queryToVector(
BlogPost.props.blogUri eqs blog.blogUri)
If you don’t want the DSL wildcard imports to infect other parts of your program, it is quite easy to localize them:
import longevity.persistence.PState
import scala.concurrent.Future
val blog: Blog = getBlogFromSomewhere()
val allPosts: Future[Vector[PState[BlogPost]]] = repo.queryToVector {
import BlogPost.queryDsl._
BlogPost.props.blogUri eqs blog.blogUri
}