Created
May 8, 2011 15:01
-
-
Save gakuzzzz/961416 to your computer and use it in GitHub Desktop.
anormの拡張
This file contains hidden or 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 play.db.anorm._ | |
import play.db.anorm.defaults._ | |
trait Identifiable[A] { | |
type ID = A | |
val id: Pk[ID] | |
} | |
trait ExMagic[A <: Identifiable[_]] extends Magic[A] { | |
def findById(id: A#ID): Option[A] = find("id = {id}").onParams(id).first() | |
def findAll: Seq[A] = find().list() | |
def delete(v: A): Boolean = deleteById(v.id()) | |
def deleteById(id: A#ID): Boolean = super.delete("id = {id}").onParams(id).execute() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment