Skip to content

Instantly share code, notes, and snippets.

@jcrosby
Created March 9, 2009 07:05
Show Gist options
  • Save jcrosby/76147 to your computer and use it in GitHub Desktop.
Save jcrosby/76147 to your computer and use it in GitHub Desktop.
// Assuming a CloudKit app hosting "notes" and "things" collections:
var store = $.cloudkit;
store.boot({
success: function() {
// insert a 'thing'
store.collection('things').insert({name:"box"}, {
success: function(index) {
// do something with your data
}
});
// insert a 'note'
store.collection('notes').insert({foo:"bar"}, {
success: function(index) {
// do something with the note
}
});
// update all 'things', setting their name to "boxen".
// See the TaffyDB docs for the optional second "where" parameter
// (excluded below) specifying a subset of documents to update.
store.collection('things').update({name:"boxen"}, {
success: function(indexes) {
// do something with your updated data
}
});
// delete all 'things' where name is "boxen".
store.collection('things').remove({name:"boxen"}, {
success: function(indexes) {
// your data is now removed
}
});
// get all 'notes'
var notes = store.collection('notes').get();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment