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

njodb-cli

v0.1.14

Published

A simple command line interface (CLI) for njodb

Downloads

18

Readme

njodb-cli

njodb-cli is a simple command-line interface (CLI) for njodb.

Table of contents

Install

One needs to install njodb-cli as a global package so that it can be executed from the command line directly:

npm install -g njodb-cli

Introduction

Start up the CLI and create or connect to an existing NJODB in the current working directory:

njodb-cli.js

Start up the CLI and create or connect to an existing NJODB in another directory:

njodb-cli.js --root /path/to/somewhere

Upon successful startup:

Connected to the database at /Users/jamesbontempo/github/njodb-cli using njodb 0.4.33
Available database methods (prepend with db. and end with ;):
	aggregate, delete, drop, grow, insert, insertFile, resize, select, shrink, stats, update
Additional commands:
	clear, details, exit, last, more
njodb>

For information about the database methods and the data they return see the njodb documentation. By default, njodb-cli uses the synchronous versions of the methods (but you don't have to include "Sync"). This allows for easy chaining, like in this example where the data returned from a select call is sorted by id:

db.select(r => r.id <= 100).data.sort((a, b) => a.id - b.id);

If for some reason you want to use the asynchronous versions of the methods, you can specify that during start-up:

njodb-cli.js --async

And then you can achieve the same result as the above example with:

db.select(r => r.id <= 100).then(results => results.data.sort((a, b) => a.id - b.id));

Some njodb method calls can be verbose, so njodb-cli allows multi-line entry (and will even try to help auto-indent):

njodb> db.aggregate(
 ... >   r => r.id <= 100,
 ... >   r => [r.region, r.state],
 ... >   r => {
 ... >     return {firstName: r.firstName, lastName: r.lastName};
 ... >   }
 ... > );

Commands

In addition to the njodb methods, there are several commands specific to njodb-cli.

clear

If a mistake is made in the process of writing a database method call (especially a particularly long one), entering clear will reset the input, clearing any entered text from memory and resetting the prompt. Typing clear while paging through a large data set returned from a select or aggregate call will also clear the data set from memory.

details

njodb methods generally return a details object that provides information specific to each datastore. By default, this information is not provided after making a method call using njodb-cli. However, entering details will provide that information.

exit

Typing exit will close njodb-cli.

last

One can retrieve the last successfully executed method call by using the last command. While one-liners can generally be retrieved by pressing the up arrow key, this is not particularly useful for calls that have been entered across multiple lines. Entering last will return the full text of multi-line calls so they can be easily re-run or edited.

more

For njodb method calls that return data (i.e, select and aggregate), njodb-cli will only display the first ten results. Typing more will retrieve the next ten records in the data set. This command can be called repeatedly to page through all of the data until there is none left.