puffer

1.1.2 • Public • Published

puffer

Build Status npm version Coverage Status

Puffer is an extendable Couchbase library for Hapi js. It uses Boom to return nicer DB errors and use Q to provide promises.

  • Full documation can be found here.
  • Source code is available at here.

How to use

You can initialize it in your server and use it in your other files or even other plugins.

Single module with many files

In your server.coffee have something like this:

Hapi = require 'hapi'
new require('puffer')( { host: '127.0.0.1', name: 'default' } )

Above line will create an instance of couchbase which you can use in your other files as an example in your userModel.coffee you can use this:

bucket = require('puffer').instance
bucket.insert( 'doc1', { color: 'red' } )
      .then( (d) -> console.log d )

Multiple Hapi Plugins

In your server.coffee have something like this:

Hapi = require 'hapi'
db = new require('puffer')( { host: '127.0.0.1', name: 'default' } )
 
server.register { 
  register: require('myPlugin'), 
  options: { bucket: db } 
}, (err) ->
  throw err if err
  server.start()

Above line will create an instance of couchbase which you should pass to plugins. In your myPlugin module you can do this:

exports.register = (plugin, options, next) ->
  bucket = options.bucket
  bucket.insert( 'doc1', { color: 'red' } )
        .then( (d) -> console.log d )

Need More?

  • Find the full list of available methods here.
  • This documentation is generated by groc, you can make a copy of in your local version.
  • You can run tests locally by npm test. Make sure you have development dependencies installed.

Readme

Keywords

none

Package Sidebar

Install

npm i puffer

Weekly Downloads

22

Version

1.1.2

License

none

Unpacked Size

24 kB

Total Files

12

Last publish

Collaborators

  • pixelsandcode
  • tectual