0.4.4 • Published 10 years ago

wheelhouse-couch v0.4.4

Weekly downloads
4
License
-
Repository
github
Last release
10 years ago

wheelhouse-couch

NPM

A wheelhouse package for using Backbone server side with flatiron. This sets Couch as the data store for the server and is largely a rewrite of backbone-couch. CouchDB communication is via the excellent cradle CouchDB library.

Usage

var flatiron = require('flatiron')
  , app = flatiron.app
  , dbPlugin = require('wheelhouse-couch')

app.use(flatiron.plugins.http, {})
app.use(dbPlugin, {
  name: 'database-name'
  , host: 'localhost' // default
  , port: 5984 // default
  // also takes cradle options
  , cache: false // disabled by default b/c cradle's cache doesn't play nicely if your app is hosted on multiple servers
  , raw: false // cradle default
  // additional advanced options
  , getId: function(model){ // used internally to get the DB id from the model. the default behavior follows: {{collectionName}}/{{UUID}}
    return model.url().substring(1) // default
  }
  , getCollectionName: function(collection){
    // you might want to override this if your collection urls don't match your collection names
    // e.g. if your collection url is '/api/collectionName', you could use: `return collection.url.split('/')[2]`
    return collection.url.substring(1) // default
  }
}, function(){} // do something after the database connection has been established
)
app.start(8999)

After using the plugin, Backbone.sync is overridden to use CouchDB on the server.

app.config.set('db:name', 'database-name')
app.config.set('db:host', 'localhost')
app.config.set('db:cache', true)
// …

Important note:

Your models should override the default id attribute to use _id.

var model = Backbone.Model.extend({
  idAttribute: '_id'
})

tests

The grunt way

You must have grunt-cli installed: sudo npm i -g grunt-cli npm test

You'll need to have a user on your db with the username test and the password test.

The Mocha way

mocha test/specs -ui bdd

Changelog

0.4.4

security fix it is no longer possible to bypass the delete method by manually setting isDeleted: true

0.4.3

Updated publish process.

0.4.2

Send updatedAt and createdAt back out when they're modified.

0.4.1

Publish error

0.4.0

  • breaking change (kinda) no longer automatically reading options from app.config.get('db') (this never really was operational anyway)
  • update the backbone/collection view to only look at ids with a / in them… for performance.
  • Add unit tests
  • Updates retry on a document update conflict
  • fix error callbacks. They now return just the response … which is as Backbone intended.
  • many methods were private before. They're now exposed in .internals
  • changes feed now removes attributes from the model that were deleted in the db
  • the delete method is now much smarter… by just re-implementing the update method
  • new createdAt and updatedAt are now automatically created and updated.

0.3.10

  • on db update error, don't log the input. It leads to log pollution.

0.3.9

  • pass notOriginal for changes feed upates. This enables ignoring of events on changes that are triggered on another server.

formerly known as flatiron-couch-backbone

0.4.4

10 years ago

0.4.3

10 years ago

0.4.1

10 years ago

0.3.10

10 years ago

0.3.9

10 years ago

0.3.8

11 years ago

0.3.7

11 years ago

0.3.6

11 years ago

0.3.5

11 years ago

0.3.4

11 years ago

0.3.3

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.20

11 years ago

0.2.19

11 years ago

0.2.18

11 years ago

0.2.17

11 years ago

0.2.16

11 years ago

0.2.15

11 years ago

0.2.14

11 years ago

0.2.13

11 years ago

0.2.12

11 years ago

0.2.11

11 years ago

0.2.10

11 years ago

0.2.9

11 years ago

0.2.8

11 years ago

0.2.7

11 years ago

0.2.6

11 years ago

0.2.5

11 years ago

0.2.4

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago