forked from pouchdb-community/ember-pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support multiple createRecord calls (fixes pouchdb-community#239)
This commit changes how ember-pouch implements `Adapter.createRecord`, which is invoked after calling `.save()` on a new record, so that it does not create multiple records if `.save()` is called more than once before the first operation has finished. If `.save()` is only invoked once before the record has finished persisting to the DB (i.e. the promise that it returns has resolved) then the behavior is unchanged. However, subsequent calls will wait for the previously returned promise to resolve and then, if changes have been made to the record, it will delegate the task to `updateRecord`. To avoid a problem caused by ember-data changing the ID associated with the internalModel/record when the record has finished persisting, the `Adapter.generateIdForRecord` method has been implemented so that it is available immediately. Previously ember-pouch had still been generating this id during `createRecord`, but ember-data was not being made aware of this until its returned promise resolved. Finally, rather than rely on `adapter.db.rel.uuid()` to generate an RFC4122 v4 UUID (requiring initialization to have completed), this has been replaced by the equivalent `uuid` module from npm, and the ember-auto-import addon has been installed to make it easy to access this from within ember-pouch.
- Loading branch information
Showing
4 changed files
with
14,908 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.