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

couchdb-change-events

v2.3.2

Published

This library will emit changes done in couchdb.

Downloads

54

Readme

Build Status Code Climate Issue Count Test Coverage

Easy interface to get object changes from CouchDb. This library is basically event emitter that emits changed objects, connection status and errors. If something happens with connection, it will be established again. Library checks also heartbeat and if new heartbeat is not received, connection will be reconnected. So Sit back and Relax, everything is taken care for you.

Key reasons why to choose this package are:

  • Follows CouchDb philosophy - Easy to use, bulletproof and you can sit back and relax.
  • When CouchDb is unreachable and comes back online, changes will be emitted again.
  • No dependencies.
  • Reports connection status.
  • Reconnects on connection fail or heartbeats are not received anymore.
  • Always will be 100% test code coverage.

CouchdbChangeEvents(options)

Options for initializing library.

  • database: Name of the database to use for this connection. (Mandatory)
  • host: The hostname of the database you are connecting to. (Default: localhost)
  • port: The port number to connect to. (Default: 5984)
  • protocol: Protocol used to connect to CouchDb. http/https (Default: http)
  • includeDocs: Include the associated document with each result. (Default: true)
  • heartbeat: Period in milliseconds after which an empty line is sent in the results. (Default: 2000)
  • lastEventId: ID of the last events received by the server on a previous connection.
  • autoConnect: If it's true then connection is started on initializing, otherwise connect function has to be called. (Default: true)
  • user: The CouchDb user to authenticate as.
  • password: The password of that CouchDb user.
  • view: Allows to use view functions as filters. Documents counted as “passed” for view filter in case if map function emits at least one record for them
  • style: Specifies how many revisions are returned in the changes array. The default, main_only, will only return the current “winning” revision; all_docs will return all leaf revisions (including conflicts and deleted former conflicts).

Usage

Quick start

const CouchdbChangeEvents = require('couchdb-change-events');

const couchdbEvents = new CouchdbChangeEvents({
  database: 'my_database'
});

couchdbEvents.on('data', (data) => {
  console.log('data', data);
});

couchdbEvents.on('couchdb_status', (status) => {
  console.log(`couchdb status: ${status}`);
});

couchdbEvents.on('couchdb_error', (error) => {
  console.log('error', error);
});

Authentication

const CouchdbChangeEvents = require('couchdb-change-events');

const couchdbEvents = new CouchdbChangeEvents({
  database: 'my_database',
  host: '127.0.0.1',
  user: 'username',
  password: 'secret'
});

couchdbEvents.on('data', (data) => {
  console.log(data);
});