Giter Site home page Giter Site logo

backbone-pouchdb's Introduction

backbone-pouchdb

A Backbone sync adapter for PouchDB (https://github.com/mikeal/pouchdb, https://github.com/daleharvey/pouchdb).

Getting started

Check out the Todo example how it works. Basically, just set a pouch property on your model or collection:

Backbone.Model.extend({
  pouch: Backbone.sync.pouch('idb://mydb')
});

You can ask backbone-pouchdb to fetch a collection via a view:

pouch: Backbone.sync.pouch('idb://todos-backbone', {
  reduce: false,
  include_docs: true,
  conflicts: true,
  view: {
    map: function(doc) {
      if (doc.type === 'todo') emit([doc.order, doc.title], null);
    }
  }
});

TODO Sync Couchapp Example

I included a couchapp version of the Todo example with synchronisation support.

You can either run it as a Couchapp with Mouch [https://github.com/jo/mouch], or run it locally from your filesystem.

Run TODO Sync from Filesystem

git clone https://github.com/daleharvey/CORS-Proxy.git
cd CORS-Proxy
node server.js

This will proxy requests to http://localhost:1234 to a local CouchDB running on http://localhost:5984, adding CORS headers.

Install TODO Sync as a Couchapp

You need the following libraries and programs installed on your system:

  • ruby
  • ruby-json
  • curl

cd to the apps directory:

cd examples/todos-sync

Install the Couchapp:

./mouch app.json.erb http://localhost:5984/todos-backbone

If your CouchDB is not in admin party mode, supply the credentials in the form:

./mouch app.json.erb http://username:password@localhost:5984/todos-backbone

and visit http://localhost:5984/todos-backbone/_design/todos/index.html

backbone-pouchdb's People

Contributors

jo avatar scttnlsn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.