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
if record not exist want make creaton based on documentation in slick
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
Post a Comment