Skip to content

Commit

Permalink
model scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
jto committed Jul 5, 2012
1 parent 98a120d commit f714030
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions sample/.g8/model/app/models/$className$.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package models

import java.util.{Date}

import play.api.db._
import play.api.Play.current

import anorm._
import anorm.SqlParser._

case class $className$(id: Pk[Long] = NotAssigned, name: String)

object $className$ {

/**
* Parse a $className$ from a ResultSet
*/
val simple = {
get[Pk[Long]]("$className;format="lower"$.id") ~
get[String]("$className;format="lower"$.name") map {
case id~name => Company(id, name)
}
}

def findAll: Seq[$className$] = DB.withConnection { implicit connection =>
SQL("select * from $className;format="lower"$ order by name").as($className$.simple *)
}

}
1 change: 1 addition & 0 deletions sample/.g8/model/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
className=Application
1 change: 0 additions & 1 deletion scaffold/src/main/scala/scaffolding-plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ object ScaffoldPlugin extends sbt.Plugin {

import ScaffoldingKeys._


import complete._
import complete.DefaultParsers._

Expand Down

0 comments on commit f714030

Please sign in to comment.