Skip to content
/ lev Public
forked from heapwolf/lev

A commandline tool and repl (with autocomplete) for querying and managing leveldb instances.

Notifications You must be signed in to change notification settings

Xorcode/lev

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

131 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

Commandline LevelDB management.

FEATURES

  • Command line data management
  • Interactive data management
  • REPL features auto-complete and suggestions for keys.
  • REPL automatically saves and reloads REPL history.
  • Connect to a network enabled database via multilevel.

INSTALLATION

$npm install lev -g

CLI EXAMPLES

$ lev

Will print out usage options. Note most commands have shorthand aliases

Get the first 10 keys in the database, the path is optional but if ommited a database will be created in the current working directory.

$ lev path/to/db --keys --limit 10

or short hand

$ lev path/to/db -kl 10

Get the first ten records starting at bazz and ending at zomg.

$ lev path/to/db --limit 10 --start 'bazz' --end 'zomg'

Get the key welcome from inside the 2 sublevels deep

lev ./db --cd greetings/en --get 'welcome'

CLI OPTIONS

If no options are supplied then a REPL is provided to either the path or port specified

Options:
  -c                  Creates a database                                                                                                                                   
  --del, -d           Remove an entity                                                                                                                                     
  --get, -g           Get an record based on the key                                                                                                                       
  --put --value, -p   Put a value into the database
                      e.g $ lev /path/to/db --put key --value val
                      Or $ lev /path/to/db -p key val
  --port              For connecting to a remote multilevel instance.
                      Use as a single option for a REPL                                              
  --keys, -k          Only return keys                                                                                                                                     
  --limit, -l         The number of entities to return                                                                                                                     
  --start, -s         The starting key for a read                                                                                                                          
  --end, -e           The end key 

For connecting to a multilevel enabled instance, specify the port parameter:

lev --port 1337 --keys ...

REPL

Start the REPL by providing only a path or host and port

$lev path/to/db

Commands in the REPL also match the API. But wait! There are a subset of commands that make common operations faster, easier and more fun. The following keys and sublevels are arbitrary and for the purpose of this example only.

ls A listing of keys in the current sublevel

Supports tab completion, same as the javascript function.

>ls
81!6dfb2cf92a411302b97a24cb977c1bd981711c
81!8613357d10da3ae2d295a53137b750d6b324b5
c9!25e7700452f8f269898cee9c18925350a6ef24
8c!699404e9c54349c32f4ca88a9ceea9382cffe9
>

get Get the value of a key and inpspect it if possible

Supports tab completion, same as the javascript function.

>get 81!6dfb2cf92a411302b97a24cb977c1bd981711c
{
  "greeting": "hello, world!"
}
>

cd create or change into a sublevel

Supports cd .. to navigate down a level. cd / to navigate to the root of the database. And cd foo/bar/bazz to navigate up to a deeply nested sublevel in the database.

>cd 97a24cb977c1bd9
/97a24cb977c1bd9>ls
c9!b5db29d11c6556b7d5b7ffe272dcefec9edae6

Default Configuration

You can create a .lev file in your home directory and it will be used to set the defaults. Command line arguments will override the default settings in this file.

{
  "createIfMissing": true,
  "encoding": "json"
}

About

A commandline tool and repl (with autocomplete) for querying and managing leveldb instances.

Resources

Stars

Watchers

Forks

Packages

No packages published