akka - Scala Slick - Omit ID column (Auto_Increment) -


i have learned scala, slick, akka 2 months , got problem when doing project of akka...

// case class use parsing data request // case class usertransaction(sender: string, recipient: string, amount: int)  //this 1 use reflecting database case class usertransactiondb(sender: string, recipient: string, amount: int, id: int)  class usertransactionmodeldb(tag: tag) extends table[usertransactiondb](tag, "usertransaction") {     def id = column[int]("id", o.primarykey, o.autoinc)     def sender = column[string]("sender")     def recipient = column[string]("recipient")      def amount = column[int]("amount")      override def * =          (sender, recipient, amount, id) <> (usertransactiondb.tupled, usertransactiondb.unapply)  } 

i want send post request (json) akka :

{"sender" : "s" , "recipient" : "r", "amount" : 100} 

now, want use 1 case class usertransaction (without "id" field in usertransactiondb) not reflect database , parse data request. possible ?

thank , sorry english !

try custom format... along these lines:

case class usertransactiondb(sender: string, recipient: string, amount: int, id: int)  object myjsonprotocol extends defaultjsonprotocol {   implicit object usertransactionjsonformat extends rootjsonformat[usertransactiondb] {     def write(c: usertransactiondb) =       jsarray(jsstring(c.sender), jsstring(c.recipient), jsnumber(c.amount))      def read(value: jsvalue) = value match {       case jsarray(vector(jsstring(sender), jsstring(recipient), jsnumber(amount))) =>         new usertransactiondb(sender, recipient, amount.toint)       case _ => deserializationerror("usertransactiondb expected")     }   } } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -