0
votes

I'm using the Slick generator to generate my tabble definitions based on my database and I would like to change a thing in the generated code. When it generates the classes it does not put my auto increment keys as Option[Int] = None in the case classes... Is there a way to do that? And maybe add an autoinc method in the table definition that returns the generated id like this for example:

def autoInc = id.? ~ name <> (User, User.unapply _) returning id
1
did you find the way on how to add a new method in a TableClass? I do not know what should be override and what should be put. I'm thinking a class with trait DefAndrew James Ramirez
I'm sorry, but I have no ideaAugusto
Ah its ok, I already got the answer ;) While playing with slick , you need to create a new Def then append it in the definitions (depends on where you want it) either in TableClassDef or TableDef or in other parts.Andrew James Ramirez

1 Answers

3
votes

The code generator already supports this. You have to set autoIncLastAsOption = true.

new SourceCodeGenerator(model){
    override def Table = new Table(_){
        override def autoIncLastAsOption = true
    }
}

Also see http://slick.typesafe.com/doc/2.0.0/code-generation.html for more help with customizing the code generator.