Last active
August 29, 2015 14:18
-
-
Save Jacoby6000/2ed314de971d8e601429 to your computer and use it in GitHub Desktop.
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
case class Address(id:Option[Long], | |
street1: String, | |
street2: Option[String] = None, | |
city: String, | |
state: String, | |
zipCode: String) extends DBObject | |
class Addresses(tag: Tag) extends IndexedTable[Address](tag, "addresses") { | |
def street1 = column[String]("street1") | |
def street2 = column[Option[String]]("street2") | |
def city = column[String]("city") | |
def zipCode = column[String]("zip_code", O.Length(10,true)) | |
def state = column[String]("state") | |
def * = (id ?, street1, street2, city, state, zipCode) <> (Address tupled, Address unapply) | |
} | |
Find Query: | |
someTable.filter(_.id === someId).list.headOption |
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
case class Address( override val id: Option[Long], | |
@Column("agency_id") agencyId: Option[Long], | |
state: String, | |
city: String, | |
@Column("cip_code") zipCode: String, | |
address1: String, | |
address2: String, | |
) extends IndexedModel[Long] with TimeStamps | |
Find Query: | |
from(someTable)(t => select(t) where(_.id === someId)).headOption |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment