How to define different setter for update and insert? #17

Open
antage opened this Issue Mar 21, 2013 · 5 comments

Comments

Projects
None yet
5 participants

antage commented Mar 21, 2013

I want to increment table field (by UPDATE) or set to 1 (by INSERT if record doesn't exist).
How can I do that with upsert?

Owner

seamusabshere commented Mar 21, 2013

upsert can't do that, yet... it's on the wishlist.

I imagine it might work something like:

selector = { id:15 }
setter = { count: Upsert.sql('count + 1') } # here's the important part
upsert.row(selector, setter)

would that work for you?

antage commented Mar 21, 2013

I see it like this:

selector = { id: 15 }
update_setter = { count: Upsert.sql('count + 1') }
insert_setter = { count: 1 }
upsert.row_with_two_setter(update_setter, insert_setter, selector)

jan commented May 22, 2015

Can anyone sketch a solution for this?

Is this possible yet?

Collaborator

pnomolos commented Mar 31, 2017

@ioquatix It's not possible yet, this is still definitely on the wishlist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment