Skip to content
Kanso package that connects spine to a pure couchapp
Pull request Compare This branch is 21 commits behind nrw:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A Kanso port of spine.todos lives here.


Add spine-adapter to your dependencies in kanso.json and run kanso fetch.

"dependencies": {
    "spine-adapter": null

require Spine modules you'll use. spine/core is required for any use of Spine. spine-adapter/couch-ajax is required to persist your models in couchdb.

# Creates the global 'Spine' object

class BlogPost extends Spine.Model
  @configure "BlogPost", "title", "body"

  # Enables CouchDB storage for instances of this model
  @extend Spine.Model.CouchAjax

To fetch a specific set of records (rather than all records of a type), use the db module to retreive a view. Pass the docs from that view to the model's refresh method.

_ = require("underscore")._

query =
  include_docs: yes
  start_key: [1323286277322]
  end_key: [1323286977322, {}]

refresh = () ->
  appdb = db.use(require('duality/core').getDBURL())
  appdb.getView, "posts_by_date", query, (err, res) ->
    BlogPost.refresh(_.pluck(res.rows, "doc")) if res?.rows

Instantiate your Spine app controller in a script tag. In this example, the module at controllers/app exports a Spine controller.

<!-- in base.html -->
<div id="content"></div>

<script type="text/javascript" charset="utf-8">
  var exports = this;
    var App = require("controllers/app");
    exports.new_app = new App({el: $("#content")});

For full documentation of how to use Spine, visit its official documentation.

Something went wrong with that request. Please try again.