Is there a CRUD generator utility in Scala (any framework) like Forests in Rails?

See: Is there a CRUD generator utility in Java (any framework) like Forests in Rails?

I have the same question but regarding Scala. I know there are generators in Play Framework 1.x, but 2.x removed them, is there any working CRUD / Scaffolding generator for any Scala based web framework?

+3


source to share


2 answers


I was looking for a scaffolding tool too (which triggered your question) and found this: http://skinny-framework.org/documentation/scaffolding.html

I did not , but the document looks like it will do the job:

./skinny g model tweet userId:Long text:String user:Option[User]

will create



package model

import skinny.orm._, feature._
import scalikejdbc._
import org.joda.time._

// If your model has +23 fields, switch this to normal class and mixin scalikejdbc.EntityEquality.
case class Tweet(
  id: Long,
  userId: Long,
  text: String,
  user: Option[User] = None,
  createdAt: DateTime,
  updatedAt: DateTime
)

object Tweet extends SkinnyCRUDMapper[Tweet] with TimestampsFeature[Tweet] {

  override lazy val defaultAlias = createAlias("t")

  lazy val userRef = belongsTo[User](User, (t, u) => t.copy(user = u))

  /*
   * If you're familiar with ScalikeJDBC/Skinny ORM, using #autoConstruct makes your mapper simpler.
   * (e.g.)
   * override def extract(rs: WrappedResultSet, rn: ResultName[Tweet]) = autoConstruct(rs, rn)
   *
   * Be aware of excluding associations like this:
   * (e.g.)
   * case class Member(id: Long, companyId: Long, company: Option[Company] = None)
   * object Member extends SkinnyCRUDMapper[Member] {
   *   override def extract(rs: WrappedResultSet, rn: ResultName[Member]) =
   *     autoConstruct(rs, rn, "company") // "company" will be skipped
   * }
   */
  override def extract(rs: WrappedResultSet, rn: ResultName[Tweet]): Tweet = new Tweet(
    id = rs.get(rn.id),
    userId = rs.get(rn.userId),
    text = rs.get(rn.text),
    createdAt = rs.get(rn.createdAt),
    updatedAt = rs.get(rn.updatedAt)
  )
}

      

hope this helps!

+2


source


Copying an answer from comments to remove this question from the No Answer filter:

No, there was talk about a user group of the game about this, nothing is planned. Twitter Bootstrap + DAO implementation + RESTful routing is your best bet; those. roll your own.

...

Check out the docs on TB [Twitter Bootstrap] integration, quite awesome, gives you a great headgear, CRUD with Play is pretty easy.



~ answer per virtualeyes

+1


source







All Articles