Hi,
I’m new to Scala and this is my first Scala question.
I’m inserting an array of data in a table ,
my console log of array (json) looks exactly like this:
productImportRequest(1,dell)
productImportRequest(2,lenovo)
productImportRequest(3,Macbook)
productImportRequest(4,Canon)
In my case statement I’m doing some validation and would like to insert if all is OK:
case j:JsSuccess[ProductImportRequest] =>
val productImportRequest= j.get
Logger.debug(" Importing... "+productImportRequest)
def create(product: Product) = {
DB.withConnection { implicit c =>
SQL("INSERT INTO products(name,) VALUES (productImportRequest);")
.on( 'name -> products.name').executeInsert()
}
}
productImportRequest.validate1 match {
case productImportResponse if productImportResponse.success =>
Logger.debug(" done")
productImportResponse
case failed =>
Logger.debug("row #"+failed.request.row+" failed - validation said: "+failed.message)
failed
}
please, could you guide me on how to bulk insert all data in productImportRequest?
Many thanks