Skip to content

Instantly share code, notes, and snippets.

@cesine
Forked from trisapeace/extended-pouchdb-backbone.js
Created September 26, 2012 19:52
Show Gist options
  • Save cesine/3790182 to your computer and use it in GitHub Desktop.
Save cesine/3790182 to your computer and use it in GitHub Desktop.
Backbone and PouchDB
var Corpus = Backbone.Model.extend({
changePouch : function(couchConnection, callback) {
this.pouch = Backbone.sync.pouch(couchConnection.pouchname);
callback();
},
saveAndInterConnectInApp : function(callback) {
callback();
}
});
var myCorpus = new Corpus({id: 2});
// GET the book from PouchDB's corpusdb database
// POST or PUT the book to PouchDB's corpusdb2 database
var Corpus = Backbone.Model.extend({
urlRoot: '/corpus'
});
var myCorpus = new Corpus({id: 2});
// GET the corpus from /corpus/2
myCorpus.fetch();
// POST or PUT the corpus to /corpus/2
myCorpus.save();
var Corpus = Backbone.Model.extend({
pouch: Backbone.sync.pouch('idb://corpusdb'),
});
var myCorpus = new Corpus({id: 2});
// GET the corpus from PouchDB's corpusdb database
myCorpus.fetch();
// POST or PUT the corpus to PouchDB's corpusdb database
myCorpus.save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment