-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add upsert support to Model.save
, Document.save
, and Document.saveAll
#142
base: master
Are you sure you want to change the base?
Conversation
This adds a second (optional) parameter to `Model.save`, which allows you to specify how conflicts should be handled when inserting documents. When `options.conflict` is set to either `update` or `replace`, documents will be updated or replaced when inserted if they already exist in the database. If the value is set to anything else it will revert to `error`. The default conflict resolution is `error`, which is in line with how it worked before since that's what RethinkDB defaults to.
It would also be great to have these same options on |
Agreed @marshall007, I'm being bitten pretty hard by that at the moment. I'll see if I can get that working as well. |
This adds a second (optional) parameter to `Document.save` and `Document.saveAll`, which allows you to specify how conflicts should be handled when inserting documents. When `options.conflict` is set to either `update` or `replace`, documents will be updated or replaced when inserted if they already exist in the database. If the value is set to anything else it will revert to `error`. The default conflict resolution is `error`, which is in line with how it worked before since that's what RethinkDB defaults to.
Model.save
Model.save
, Document.save
, and Document.saveAll
Ok so I hacked something in for myDocument.saveAll(null, { conflict: 'replace' }) Ain't pretty. |
Err I'm really sorry, I missed this pull request -_- I'll add options for Again, really sorry @mstade for missing your pull request :/ |
+1 (Document.save) |
@neumino Don't worry about it buddy, it's easily done in all the noise! Since publishing this PR I've moved on to other things and am no longer actively using either RethinkDB and thus not thinky either. At the time, missing upsert was a big deal(tm) and a pretty big gotcha. Whether this is still true with current versions of thinky I wouldn't know, so you may want to consider just closing this PR or creating a new issue to deal with this for a more up-to-date code base. Finally – thanks for your great efforts to bring better tools to the developer community! |
This adds a second (optional) parameter to
Model.save
,Document.save
,and
Document.saveAll
; which allows you to specify how conflicts should behandled when inserting documents.
When
options.conflict
is set to eitherupdate
orreplace
, documentswill be updated or replaced when inserted if they already exist in the
database. If the value is set to anything else it will revert to
error
.The default conflict resolution is
error
, which is in line with how itworked before since that's what RethinkDB defaults to.