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-wedge

v1.2.4

Published

CLI and node modules for doing bulk operations like deleting all databases on a server or replicating all databases from one server to another.

Downloads

25

Readme

CouchDB Wedge

CLI and node module for doing bulk operations like deleting all databases on a server or replicating all databases from one server to another.

Install

npm install -g couchdb-wedge

Wedge is a command that consists of many other sub-commands, see below.

 λ wedge --help

  Usage: wedge [options] [command]


  Commands:

  replicate-all-dbs    replicate all databases from one couchdb to another
  delete-all-dbs       delete all databases on a couchdb
  pre-warm-views       Hit all views in a couchdb to pre-warm them
  restore-deleted-doc  Undelete a doc
  pull-json            Pull documents from a View in CouchDB returning just an array of the documents, not additional metadata that CouchDB usually does.
  push-json            Push an array of documents to a CouchDB database. Accepts STDIN over a pipe.
  doc-history          Revs with docs attached
  subscribe            Subscribe to the changes feed of a database and act on it.
  help [cmd]           display help for [cmd]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

Example of subscribing to a changes feed and changing every foo property that is false to true

The subscribe command can help with schema transformations and progressive data updates. When running, the subscribe command listens for new changes, and when new changes are detected, processes them in batches. With each change, you can have a custom action performed. If the processing is interrupted at any point, the command stores a state file on disk to track where it last left in the changes feed.

If the following example, any doc that has a property of foo with a value of false will be set to true.

Place the following in an action.js file in the directory you run the command:

module.exports = async function (change, db) {
  console.log(change)
  const doc = await db.get(change.id)
  // Warning: If you don't check that something is done, it will be an infinite loop.
  if (doc.foo === false) {
    doc.foo = true
    db.put(doc)
  }
}
wedge subscribe --url http://admin:[email protected]:5984/some-database

Example of a pull replication of all databases except for _replicator and resources

wedge replicate-all-dbs --worker https://username:[email protected] --target https://username:[email protected] --source https://username:[email protected] --exclude _replicator,resources

Example of deleting all databases on a server except for _replicator and _users

wedge delete-all-dbs --target http://username:[email protected] --exclude _replicator,_users

This command has a prompt asking the user to confirm the action.

Example of pre-warming CouchDB view cache, which forces generation of index for all databases on the couch server.

wedge pre-warm-views --target http://username:[email protected]

This command has a prompt asking the user to confirm the action.

Develop

Get the code and set your own wedge command to resolve to that codebase.

git clone [email protected]:rjsteinert/CouchDB-Wedge.git
cd CouchDB-Wedge
npm link