Experimental helper objects for interacting with data stored in Cloudant
JavaScript CSS
Latest commit 972f671 Dec 12, 2013 @drsm79 drsm79 Update README.md

README.md

Backbone Cloudant

Helper objects for interacting with data stored in Cloudant from Backbone.

This is an experimental project to demo the ease of using Cloudant with Backbone. 
There's an open question around how auth gets done neatly, partly because that is very
application dependent, but the rest of the code is in a usable state.

Getting Started

Download the production version or the development version. The code depends on Backbone and Underscore only.

In your web page:

<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script src="dist/backbone.cloudant.min.js"></script>
<script>
  Backbone.Cloudant.database = "/backbone-cloudant-demo/";
  // start the change handler
  Backbone.Cloudant.changeHandler();

  var all_docs = new Backbone.Cloudant.Docs.Collection();
  var all_docs_view = new MyView({collection: all_docs, id: '#all_docs'});

  all_docs.fetch().fail(function(){console.log('Could not load all_docs collection');});

</script>

Documentation

Documentation is generated with docco. You can generate the docs using grunt docs if you have installed the dev dependencies.

Installation

  • npm install
  • Edit url.json to point to your database

Known issues

  • Need a decent way of handling auth details
  • Improve collection initialize
  • grunt-couchapp can't delete authenticated URL's

Using Backbone.Cloudant with Apache CouchDB

There is nothing that prevents using Backbone.Cloudant with CouchDB where the two systems have feature parity. The Search collection isn't usable with CouchDB, as that functionality is only available via Cloudant. All other collections and change handling should work with CouchDB and are tested on CouchDB as well as Cloudant.

Examples

Release History

  • 3rd August 2013: v0.0.2 - updated for grunt 0.4.x and clarified naming of Index collections
  • 17th September 2012: v0.0.1 - released for public testing

License

Copyright (c) 2012, 2013 Cloudant

Licensed under the MIT license.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Important notes

Please don't edit files in the dist subdirectory as they are generated via grunt. You'll find source code in the src subdirectory!

While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the test/*.html unit test file(s) in actual browsers.

Installing grunt

This assumes you have node.js and npm installed already.

  1. Test that grunt is installed globally by running grunt --version at the command-line.
  2. If grunt isn't installed globally, run npm install -g grunt to install the latest version. You may need to run sudo npm install -g grunt.
  3. From the root directory of this project, run npm install to install the project's dependencies.

Installing PhantomJS

In order for the qunit task to work properly, PhantomJS must be installed and in the system PATH (if you can run "phantomjs" at the command line, this task should work).

Unfortunately, PhantomJS cannot be installed automatically via npm or grunt, so you need to install it yourself. There are a number of ways to install PhantomJS.

Note that the phantomjs executable needs to be in the system PATH for grunt to see it.