Skip to content

Instantly share code, notes, and snippets.

@ahx
Created November 5, 2013 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahx/7326500 to your computer and use it in GitHub Desktop.
Save ahx/7326500 to your computer and use it in GitHub Desktop.
// adapters/application.js
var ApplicationAdapter = DS.Adapter.extend({
init: function() {
this.hoodie = window.hoodie; // FIXME?
this._super();
},
find: function(store, type, id) {
return this.hoodie.store.find(type.typeKey, id);
},
findAll: function(store, type, since) {
return this.hoodie.store.findAll(type.typeKey);
},
createRecord: function(store, type, record) {
return this.hoodie.store.add(type.typeKey, record.toJSON());
},
updateRecord: function(store, type, record) {
return this.hoodie.store.update(type.typeKey, record.get('id'), record.toJSON());
},
deleteRecord: function(store, type, record) {
return this.hoodie.store.remove(type.typeKey, record.get('id'));
}
});
export default ApplicationAdapter;
// serializers/application.js
var ApplicationSerializer = DS.JSONSerializer.extend({
primaryKey: '_id'
});
export default ApplicationSerializer;
@ahx
Copy link
Author

ahx commented Nov 5, 2013

Are we done yet?
TODO: How to use embedded records?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment