Skip to content

Running manual insert or update queries? #1

@tominated

Description

@tominated

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions