Skip to content

Instantly share code, notes, and snippets.

@Blackmist
Created May 13, 2013 15:40
Show Gist options
  • Save Blackmist/5569258 to your computer and use it in GitHub Desktop.
Save Blackmist/5569258 to your computer and use it in GitHub Desktop.
Ember-model-based adapter that uses the Windows Azure Mobile Services client.
// ember-model-based adapter
Ember.WAMAdapter = Ember.Object.extend({
table: null,
init: function() {
this.table = this.get('table');
},
find: function(record, id) {
var query = this.table.where({ id: id });
return query.read().then(function(data) {
Ember.run(record, record.load, data);
});
},
findAll: function(klass, records) {
return this.table.read().then(function(data) {
Ember.run(records, records.load, klass, data);
});
},
findQuery: function(klass, records, params) {
var query = this.table.where(params);
return query.read().then(function(data) {
Ember.run(records, records.load, klass, data);
});
},
createRecord: function(record) {
return this.table.insert(record.toJSON()).then(function(data) {
Ember.run(function() {
record.load(data.id, data);
record.didCreateRecord();
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment