scala - Slick update fields based on its context -


i new in slick , scala , have following question. want find if there record on database based on same timestamp. table has (id, timestamp, steps, location, direction)

1.measurements.filter(_.timestamp === operated_item.timestamp) // measurements tablequery

  1. if record not exist want make creaton based on documentation in slick

  2. if record exists then:

a. if steps there want update location , direction

b. if steps not there, want update steps.

how can these steps, right have that:

def operation(user_id: long, operated_item: measure) = {  val measurementsoperations = new measurementsoperations(db)  val q = {             c <- measurements.filter(_.timestamp===operated_item.timestamp).filter(_.steps =!= operated_item.timestamp)         } yield (c.steps)         val act = q.update(operated_item.steps)          db.run(act)  } 

i think have this: filtering , mixing monads in slick comprehension , cats

but not know how create nests.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -