I'm using this in one of my projects at work, and one of the features I'm implementing needs some stuff that doesn't seem possible with the insert-record or update-values functions. I'm trying to increment a counter in a row. If I was doing it in SQL I would do something along the lines of this:
UPDATE posts
SET likes = likes + 1
WHERE id = ?
I had noticed the with-db macro, but when looking at the official clojure jdbc library, they say that with-connection is deprecated and shouldn't be used. Is there a way to just run a query like this?
Also, how would I go about doing a database transaction?
Thanks for any help!
Tom
I'm using this in one of my projects at work, and one of the features I'm implementing needs some stuff that doesn't seem possible with the
insert-recordorupdate-valuesfunctions. I'm trying to increment a counter in a row. If I was doing it in SQL I would do something along the lines of this:I had noticed the
with-dbmacro, but when looking at the official clojure jdbc library, they say thatwith-connectionis deprecated and shouldn't be used. Is there a way to just run a query like this?Also, how would I go about doing a database transaction?
Thanks for any help!
Tom