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.
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 is generated with docco. You can generate
the docs using grunt docs
if you have installed the dev dependencies.
- npm install
- Edit
url.json
to point to your database
- Need a decent way of handling auth details
- Improve collection initialize
- grunt-couchapp can't delete authenticated URL's
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.
- 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
Copyright (c) 2012, 2013 Cloudant
Licensed under the MIT license.
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.
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.
This assumes you have node.js and npm installed already.
- Test that grunt is installed globally by running
grunt --version
at the command-line. - If grunt isn't installed globally, run
npm install -g grunt
to install the latest version. You may need to runsudo npm install -g grunt
. - From the root directory of this project, run
npm install
to install the project's dependencies.
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.
- PhantomJS and Mac OS X
- PhantomJS Installation (PhantomJS wiki)
Note that the phantomjs
executable needs to be in the system PATH
for
grunt to see it.