Skip to content

Instantly share code, notes, and snippets.

@trisapeace
Created September 26, 2012 00:37
Show Gist options
  • Select an option

  • Save trisapeace/3785310 to your computer and use it in GitHub Desktop.

Select an option

Save trisapeace/3785310 to your computer and use it in GitHub Desktop.
Backbone and PouchDB
var Meal = Backbone.Model.extend({
changePouch : function(couchConnection, callback) {
this.pouch = Backbone.sync.pouch(couchConnection.pouchname);
callback();
},
saveAndInterConnectInApp : function(callback) {
callback();
}
});
var myMeal = new Meal({id: 2});
// GET the book from PouchDB's mealsdb database
// POST or PUT the book to PouchDB's mealsdb2 database
var Meal = Backbone.Model.extend({
urlRoot: '/meals'
});
var myMeal = new Meal({id: 2});
// GET the book from /meals/2
myMeal.fetch();
// POST or PUT the book to /meals/2
myMeal.save();
var Meal = Backbone.Model.extend({
pouch: Backbone.sync.pouch('idb://mealsdb'),
});
var myMeal = new Meal({id: 2});
// GET the meal from PouchDB's mealsdb database
myMeal.fetch();
// POST or PUT the meal to PouchDB's mealsdb database
myMeal.save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment