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="https://github.com/cloudant-labs/backbone.cloudant/raw/master/jquery.js"></script>
<script src="https://github.com/cloudant-labs/backbone.cloudant/raw/master/underscore.js"></script>
<script src="https://github.com/cloudant-labs/backbone.cloudant/raw/master/backbone.js"></script>
<script src="https://github.com/cloudant-labs/backbone.cloudant/raw/master/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.
url.json
to point to your databaseBackbone.Cloudant
with Apache CouchDBThere 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.
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.
grunt --version
at the
command-line.npm install -g grunt
to install
the latest version. You may need to run sudo npm install -g grunt
.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.
Note that the phantomjs
executable needs to be in the system PATH
for
grunt to see it.