Created
May 13, 2013 15:40
-
-
Save Blackmist/5569258 to your computer and use it in GitHub Desktop.
Ember-model-based adapter that uses the Windows Azure Mobile Services client.
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
// 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