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

bos-couchdb

v0.2.3

Published

CouchDB service for BlueOak Server

Downloads

4

Readme

bos-couchdb

Build Status npm version

This is a CouchDB service for BlueOak Server. The service provides a convenient way of accessing couchdb servers through BlueOak Server. Under the covers the service uses nano.

Installation

$ npm install bos-couchdb

Configuration

This service can be configured through the couchdb field of the BlueOak Server config.

Connections

Connections are named based on key specified in the connections section of the couchdb config block. The configuration below defines two connections, one to a remote Cloudant server named cloudant and another to a local couchdb server name local.

Databases

Each connection can include on more databases defined in the databases field of the connection. The key used will correspond to the name of an actual database on the couchdb server. The configuration below defines two databases: profiles belonging to the cloudant connection, and devices belonging to the local connection.

"couchdb": {
  "connections": {
    "cloudant": {
      "url": "https://example.cloudant.com/",
      "username": "foo",
      "password": "passw0rd",
      "databases": {
        "profiles": {}
      }
    },
    "local": {
      "url": "http://127.0.0.1:5984/",
      "databases": {
        "devices": {}
      }
    }
  }
}

Scoped Config Options

Scoped config are options that can be set on the root couchdb object, the connection, or the database. The database-specific value has precedence over the connection-specific value. The connection-specific value has precedence over the root value.

This allows the definition of global values that can be overridden as desired.

Valid options are:

  • validateConnection (default true) - verify the ability to connect to the database when the server starts.
  • createDatabase (default false) - attempt to create the database if it doesn't exist when the server starts.

Usage

The bos-couchdb service can be injected into services or handlers through a bosCouchdb parameter on the init method.

exports.init = function(config, logger, bosCouchdb) {
  ...
}

getConnection(connectionName)

The getConnection function will return a named connection where connectionName corresponds to a connection specified in the configuration. The nano database functions can be used on the connection object.

var conn = bosCouchdb.getConnection('local');
conn.list(function(err, results) {
  //results is a list of databases on the connection
});

get(dbName)

The get function will return a database where dbName corresponds to a database defined in the configuration. The nano document functions can be used on the db object.

var profilesDb = bosCouchdb.get('profiles');
profilesDb.get('foo' /*doc id*/, function(err, body) {
  if (!err)
    console.log(body);
});

Since it's possible that more than one connection will share a database name, the database name can be prefixed with the connection name. This will avoid any possible ambiguity in looking up a database.

var profilesDb = bosCouchdb.get('cloudant:profiles');
var devicesDb = bosCouchdb.get('local:devices');