Skip to content

Instantly share code, notes, and snippets.

@alexmipego
Created October 9, 2014 15:34
Show Gist options
  • Save alexmipego/62361c8889db85ca4340 to your computer and use it in GitHub Desktop.
Save alexmipego/62361c8889db85ca4340 to your computer and use it in GitHub Desktop.
App.mydb.changes({
since: 'now',
live: true
}).on('change', function(docChanges) {
console.log('changed', docChanges)
if (docChanges.deleted) {
var underscore = docChanges.id.indexOf('_'),
docType = docChanges.id.substring(0, underscore),
docId = docChanges.id.substring(docChanges.id.indexOf('_', underscore + 1) + 1);
recordArray.store.find(docType, docId).then(function(record) {
if (docChanges.deleted) {
record.transitionTo('deleted.saved');
}
console.log('afterModel update', arguments, me);
});
}
recordArray.update();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment