Open terhechte opened 10 years ago
Same problem here. Is there any hope?
We can do:
(update entity
(set-fields {:col (raw "col +1")})
(where {:id [= 5]}))
Any chance of a way to avoid raw
all together?
There's no support for this in Korma.
To be honest, I don't even know how the API should look like but I'm happy to take a pull request if somebody wants to take a stab at this.
I think it would be best if you just passed a function that takes one argument, the old value, and returns the new value, like how one normally updates atoms with assoc(-in), update(-in), swap(-in) functions. That could be:
(update entity
(swap-fields {:col inc})
(where {:id [= 5]}))
Is there a way to use database operators in the set-fields part of an update operation?
i.e.
I'm currently doing this with a complete
(exec-raw)
call. I know that I could query for document 5 and then process the increments or other operations in Clojure, but I'd rather not have to perform an additionalselect
query to achieve this.I've checked the docs and had a look at the source but could not find anything, I may have missed it though.