Last active
January 17, 2017 21:00
-
-
Save jacobm/982c1f38d691b299f8492359a0eae1ad to your computer and use it in GitHub Desktop.
Basic quill example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
import io.getquill._ | |
import scala.concurrent.{Await, ExecutionContext} | |
import scala.concurrent.duration._ | |
import org.joda.time.DateTime | |
case class Users( | |
id: String, | |
paymentStatus: String, | |
createdAt: Date, | |
purchasedAt: Option[Date], | |
expireAt: Option[Date] | |
) | |
case class Messages( | |
id: String, | |
userId: String, | |
createdAt: Date | |
) | |
object Main extends App { | |
implicit val ec = ExecutionContext.global | |
implicit lazy val ctx = new MysqlAsyncContext[Literal]("db.default") | |
import ctx._ | |
val fisk = Await.result(run(quote(query[Users])), 10 seconds) | |
val q = quote { (id: String) => | |
query[Users] | |
.leftJoin(query[Messages]) | |
.on((user, msg) => user.id == msg.userId) | |
.filter(_._1.id == id) | |
} | |
val hest = Await.result(run(q("cigs5srut00121cqo0c0fbnon")), 10 seconds) | |
println("dingo") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment