Have ideas to improve npm?Join in the discussion! »


0.0.2 • Public • Published


Seneca node.js data-storage plugin for Couchbase

This module is a plugin for the Seneca framework. It provides a storage engine that uses Couchbase to persist data. This module is for production use. It also provides an example of a document-oriented storage plugin code-base.

The Seneca framework provides an ActiveRecord-style data storage API. Each supported database has a plugin, such as this one, that provides the underlying Seneca plugin actions required for data persistence.


If you're using this module, feel free to contact me on twitter if you have any questions! :) @davidmarkclem

Current Version: 0.0.2

Tested on: Node 0.10.26, Seneca 0.5.17

Quick example

var seneca = require('seneca')()
seneca.use('couchbase-store', {
  name: 'bucketname',
  host: '',
  port: 8091
  var apple = seneca.make$('fruit')
  apple.name  = 'Pink Lady'
  apple.price = 0.99
    console.log( "apple.id = "+apple.id  )


npm install seneca
npm install seneca-couchbase-store


You don't use this module directly. It provides an underlying data storage engine for the Seneca entity API:

var entity = seneca.make$('typename')
entity.someproperty = "something"
entity.anotherproperty = 100
entity.save$( function(err,entity){ ... } )
entity.load$( {id: ...}, function(err,entity){ ... } )
entity.list$( {property: ...}, function(err,entity){ ... } )
entity.remove$( {id: ...}, function(err,entity){ ... } )


The object passed as the second parameter of seneca.use can contain the following

  • name - name of the bucket to connect to
  • bucket - alias for name (default: 'default')
  • host - address of couchbase server (default: '')
  • server - alias for host
  • port - the port on which the server resides (default: 8091). If desired the port can instead be provided with host, e.g.
  • connection - pass a node-couchbase Connection object directly to the store, if set name/bucket host/server and port will be ignored
  • keyPrefix - it's recommend with couchbase to use as few buckets as possible, no more than 5. In this case, couchbase-store can use namespacing to differentiate keys in a bucket that belong to the store plugin If unset, the default keyPrefix will be 'seneca-'. To have no keyPrefix use keyPrefix: ''


The standard Seneca query format is supported:

  • entity.list$({field1:value1, field2:value2, ...}) implies pseudo-query field1==value1 AND field2==value2, ...
  • entity.list$({f1:v1,...},{sort$: 'descending'}) sorts by descending id, can also be ascending (default)
  • entity.list$({f1:v1,...},{limit$:10}) means only return 10 results (default)
  • entity.list$({f1:v1,...},{skip$:5}) means skip the first 5
  • you can use sort$, limit$ and skip$ together

Native Driver

As with all seneca stores, you can access the native driver, in this case, the returned instance of instantiating the node-couchbase Connection instance.

The native driver is accesssed using entity.native$(function(err, db){...}).


Tests do not require a couchbase server to be running, it uses node-couchbase modules Mock tool.

To run tests (within seneca-couchbase-store folder):

npm install
npm test

To test against a live server edit test/couchbase.test.js, comment out the "connection" property, and uncomment host, port and name properties, filling it appropriate details as relevant.


npm i seneca-couchbase-store

DownloadsWeekly Downloads






Last publish


  • avatar