New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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?

@seamusabshere

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

jan commented May 22, 2015

Can anyone sketch a solution for this?

@ioquatix

This comment has been minimized.

ioquatix commented Feb 18, 2017

Is this possible yet?

@pnomolos

This comment has been minimized.

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