Skip to content
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
Open

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

antage opened this issue Mar 21, 2013 · 5 comments

Comments

@antage
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link

jan commented May 22, 2015

Can anyone sketch a solution for this?

@ioquatix
Copy link

Is this possible yet?

@pnomolos
Copy link
Collaborator

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants