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

pouch-cli

v0.0.1

Published

A Node.js CLI powered by PouchDB that let you do basic commands on your CouchDB,Cloudant and PouchDB databases.

Downloads

6

Readme

#pouch-cli Inspired from pouchdb-dump-cli. This module let you perform basic operations on Cloudant/CouchDB/PouchDB databases. The main mission of this module is to give quick commands to daily operations on your database. You can access it via the CLI or directly using the library.

This is currently under development so use it at your own risks.

#Table of content

#Installation To install this package, simply run this command: npm i pouch-cli. If you plan to use the CLI, I suggest that you install it globally like this: npm i -g pouch-cli.

#CLI

Once installed, you can use this command to access the CLI: pouch-cli.

#Changelog

Coming soon.

#Commands

For every commands you use, they are some global options that you need or can set.

| Option | Alias | Type | Default | Required | Description | | ------ | ----- | ---- | ------- | -------- | ----------- | | -d | --db | string | | Yes | The url of the database on which you want to execute your commands. | | -u | - - username | string | No | | The username for access to the database (if securized) | | -p | - - password | string | No | | Option to set the password to use during the query. |

##Document's commands

###select <command>

To access the select commands, simply run: pouch-cli select --help.

At this level, you still have other global options.

| Option | Alias | Type | Default | Description | | ------ | ----- | ---- | ------- | ----------- | | -k | --keys | Array|string | | Can be either an array of keys to fetch or a single key to fetch. | | -r | --rev | boolean | true | Determine if the documents must be returned with their revision. | | -e | --with-error | boolean | false | Determine if the document with errors should be returned. | | -o | --output-file | string | | The path there the response should be saved.

From this point, you have three possible subcommands to use.

####select normal The normal select let you query the database and select particulars documents base on their ids.

For example, if we want to get the document with the _id test_doc, we would do the following:

pouch-cli select normal -k test_doc -d "http://localhost:5984/db"

You can also fetch multiple keys:

pouch-cli select normal -k "test_doc" "test_doc2" -d "http://localhost:5984/db"

####select view <design/view_name>

The view subcommand let you query the documents from one of your view. It's the same usage as for the normal command except that you must specify the viewname. Here's an example:

pouch-cli select view "design_doc/view_name" -d "http://localhost:5984/db"

####select dynamic <indexkey>

The dynamic subcommand let you query more dynamic queries. This is only generating basic javascript queries for you. This is not an efficient way to query your database but this can be useful for quick operations. The index key defines on what field should the document be queried. For example, if you want to get the documents based on the name, the indexkey would be name. You can also make temporary queries by using the (-udd false) option(see note below).

Note: Since CouchDB 2.0 release, the temporary views are disabled. Since PouchDB queries with temporary views are not working, you have to create a design document for your queries. Also, be aware that views are created based on the index key. For example, if you query by the name, you will have a view named "by_name".

pouch-cli select dynamic "name" -k "John" -d "http://localhost:5984/db"

###delete <command>

The delete command is very similar to the select command. It let you query the documents but instead of returning the results, it deletes it. Here are listed the different global options available for this command :

| Option | Alias | Type | Default | Description | | ------ | ----- | ---- | ------- | ----------- | | -k | --keys | Array|string | | Can be either an array of keys to fetch or a single key to fetch. |

####delete normal [keys]

This command is very simple. It is simply querying all the documents by the keys. If you do not specify any keys, all of the documents will be deleted.

Command examples :

pouch-cli delete normal -d "http://localhost:5984/db"

For a specific key :

pouch-cli delete normal -d "http://localhost:5984/db" -k "specific_id"

For multiple keys :

pouch-cli delete normal -d "http://localhost:5984/db" -k "first_id" "second_id"

####delete view <design/view_name> [keys]

The view subcommand let you delete the documents from one of your view. It's the same usage as for the normal command except that you must specify the viewname. Here's an example:

pouch-cli delete view "design_doc/view_name" -d "http://localhost:5984/db"

####delete dynamic <indexkey> [keys]

The dynamic subcommand let you delete document dynamically. This is only generating basic javascript queries for you. This is not an efficient way to query and delete documents from your database but this can be useful for quick operations. The index key defines on what field should the document be queried. For example, if you want to get the documents based on the name, the indexkey would be name. You can also make temporary queries by using the (-udd false) option(see note below).

Note: Since CouchDB 2.0 release, the temporary views are disabled. Since PouchDB queries with temporary views are not working, you have to create a design document for your queries. Also, be aware that views are created based on the index key. For example, if you query by the name, you will have a view named "by_name".

pouch-cli delete dynamic "name" -k "John" -d "http://localhost:5984/db"

#Notes This package is not stable yet, so don't put it in a production environment. CLI parameters and functions might change. I will try to write a changelog if it happens.

#Contributions?

Since this module is fresh from the woods, I'm not very strict on the way of contributing to this module. Feel free to submit bugs and feature request. As the owner, I will make my possible to solve the issues and develop feature requests on my free time.

Any new feature can be discussed so it gets well implemented in the current module. Do your Pull Request with a clear understanding message of what you have done. Tests would be appreciated!

#Contact

Gitter chat

You can contact me via email at [email protected].