npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wheelhouse-couch

v0.4.4

Published

A wheelhouse library to use couchdb as a database while useing backbone on ther server.

Downloads

73

Readme

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