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.
Merge remote-tracking branch 'upstream/master' into stevebest
* upstream/master: (32 commits) fixing readme reference to config key, concerning adapter blueprint. 3.2.1 Fix(Addon): Call super in init 3.2.0 Add relationship documentation Update README.md update readme update readme 3.1.1 (pouchdb-community#16) - Add override so serialiser saves hasMany Pouch adapter now calls a hook method when encountering a change for a record that is not yet loaded. update readme 3.1.0 Fix version check for Ember Data 3.2.x Update changelog for pouchdb-community#103 Tests for existing change watcher behavior Factor out integration test setup into module helper Move blueprint files into explicit directories Changelog for pouchdb-community#101 and pouchdb-community#102. created blueprint for pouch-adapter ...
- Loading branch information
Showing
22 changed files
with
679 additions
and
118 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.RESTSerializer.extend({}); | ||
export default DS.RESTSerializer.extend({ | ||
_shouldSerializeHasMany: function() { | ||
return true; | ||
}, | ||
|
||
// This fixes a failure in Ember Data 1.13 where an empty hasMany | ||
// was saving as undefined rather than []. | ||
serializeHasMany(snapshot, json, relationship) { | ||
this._super.apply(this, arguments); | ||
|
||
const key = relationship.key; | ||
|
||
if (!json[key]) { | ||
json[key] = []; | ||
} | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"predef": [ | ||
"console" | ||
], | ||
"strict": false | ||
} |
32 changes: 32 additions & 0 deletions
32
blueprints/pouch-adapter/files/__root__/adapters/__name__.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Adapter } from 'ember-pouch'; | ||
import PouchDB from 'pouchdb'; | ||
import config from '<%= dasherizedPackageName %>/config/environment'; | ||
import Ember from 'ember'; | ||
|
||
const { assert, isEmpty } = Ember; | ||
|
||
function createDb() { | ||
let localDb = config.emberPouch.localDb; | ||
|
||
assert('emberPouch.localDb must be set', !isEmpty(localDb)); | ||
|
||
let db = new PouchDB(localDb); | ||
|
||
if (config.emberPouch.remoteDb) { | ||
let remoteDb = new PouchDB(config.emberPouch.remoteDb); | ||
|
||
db.sync(remoteDb, { | ||
live: true, | ||
retry: true | ||
}); | ||
} | ||
|
||
return db; | ||
} | ||
|
||
export default Adapter.extend({ | ||
init() { | ||
this._super(...arguments); | ||
this.set('db', createDb()); | ||
} | ||
}); |
Oops, something went wrong.