Created
September 26, 2012 00:37
-
-
Save trisapeace/3785310 to your computer and use it in GitHub Desktop.
Backbone and PouchDB
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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(); |
This file contains hidden or 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
| 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