开发者

liftweb mapper - setting table name in lower case

开发者 https://www.devze.com 2023-01-11 10:30 出处:网络
Is it possible to force liftweb map开发者_高级运维per use table name in lower case for querying models?You can override dbTableName in your MetaMapper

Is it possible to force liftweb map开发者_高级运维per use table name in lower case for querying models?


You can override dbTableName in your MetaMapper

object ModelClass extends ModelClass with LongKeyedMetaMapper {
    override def dbTableName = "model_class"
}


If you want a uniform way of generating your table and column names, you should set the MapperRules.{tableName,columnName} PartialFunctions. So, if you want all of your tables and columns to be snake case, include the following two lines in your Boot.scala file:

MapperRules.tableName = (_, name) => StringHelpers.snakify(name)
MapperRules.columnName = (_, name) => StringHelpers.snakify(name)

This avoids the extraneous boilerplate of overriding the dbTableName on each class.

0

精彩评论

暂无评论...
验证码 换一张
取 消