Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-iterator

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-iterator

A fast and easy to ease CouchDB iterator for views and all documents

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
98
increased by880%
Maintainers
1
Weekly downloads
 
Created
Source

couchdb-iterator

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

A fast and easy to ease CouchDB iterator for views and all documents.

Installation

$ npm install couchdb-iterator

Usage

.couchdbIterator(couchdbAddr, [view], iterator, [options])

Calls iterator for all rows of the database referenced by couchdbAddr. If a view is supplied, iterates only over that view's rows.

This library aims to be fast, therefore iteration happens concurrently. The iterator function can be async but beware that order is not guaranteed.

Examples:

const couchdbIterator = require('couchdb-iterator');

// Iterate over all rows of a database
couchdbIterator('http://localhost:5984/my-db', 'my-designdoc/my-view', (row, index) => {
    console.log(index, row.id, row.key, row.value);
    // Do something with `row`; you may return a promise here
})
.then((rowsCount) => {
    console.log(`Iteration completed! ${rowsCount}`);
}, (err) => {
    console.log('Iteration failed', err);
});

// Iterate over all rows of a view
couchdbIterator('http://localhost:5984/my-db', 'my-designdoc/my-view', (row, index) => {
    console.log(index, row.id, row.key, row.value);
    // Do something with `row`; you may return a promise here
})
.then((rowsCount) => {
    console.log(`Iteration completed! ${rowsCount}`);
}, (err) => {
    console.log('Iteration failed', err);
});

The couchdbAddr argument must be connection string with protocol, host, port and database path (e.g.: http://localhost:5984/my-db) or a nano instance. The view argument is a string in the form of designdoc/view (e.g.: app/byUser).

Available options:

  • concurrency: The concurrency in which the iterator is called, defaults to 50.
  • nano: Custom options to be used when creating the nano instance, defaults to null.
  • The following querying options are available: limit, skip, stale, descending, startkey, startkey_docid, endkey, endkey_docid, include_docs and inclusive_end (can be camelCased).

All querying options have no default value, except for limit which is 500. Also, stale is automatically set to ok after the first iteration to further improve performance.

Tests

$ npm test
$ npm test-cov to get coverage report

License

Released under the MIT License.

Keywords

FAQs

Package last updated on 11 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc