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

njodb-cli

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

njodb-cli

A simple command line interface (CLI) for njodb

  • 0.1.14
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 25 Feb 2023

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