MonsterDB – Command Line Interface (CLI)

command line interface

monster has a command line interface for performing all actions that are available from the API

Starting CLI

monsterCLI is used to start a database server, connect to a database server or run a loadFile process, the commands are detailed below

Start a Server

java -jar monsterDB.jar -s -p <port> -a <auth file>

============================================
Starting the MonsterDB thread pool server...
============================================
To increase the java memory available for the server use the following syntax:
java -Xmx3G -server -jar monsterDB.jar -s
Where 3G in this case represents 3GB of maximum main memory, if this isn’t available when the process needs it then it will still fail, to reserve this memory from the startup you can also use:
java -Xms3G -Xmx3G -server -jar monsterDB.jar -s
In the even the server cant allocate this amount of memory it will not start the monsterDB server

Your authFile should look like this:
{ identifier: "robert", password: "123", accountType: ""}
{ identifier: "robert2", password: "123", accountType: ""}

Getting Help

java -jar monsterDB.jar -?

Produces the following help:

Usage: <main class> [-s] [-a=<auth>] [-c=<collection>] [-d=<db>]

                   [-f=<filename>] [-h=<host>] [-o=<propertiestr>] [-p=<port>]

                   [-pw=<password>] [-r=<command>] [-t=<tableName>]

                [-u=<username>]

  -a, --auth=<auth>       Authentication settings

  -c, --collection=<collection>

                          Collection to load

  -d, --db=<db>           connect the DB

  -f, --file=<filename>   File to load

  -h, --host=<host>       Remote host IP or DNS Name

  -o, --options=<propertiestr>

                          Load options

  -p, --port=<port>       Remote host port (default 27018)

      -pw, --password=<password>

                          The usernames password

  -r, --run=<command>     Run the following command

  -s, --start             Start a server

  -t, --recordType=<tableName>

                          Record Type to load (fuzzy tables only)

  -u, --user=<username>   The username to connect with

Connect to a Server

java -jar monsterDB.jar

Is the simplest form of connecting to the server running on the same machine at the default port setting:

Connected to localhost
monsterDB>

To be more specific over where to connect to:

java -jar monsterDB.jar -p 27018 -h myhost

-p specifies the port and -h the server to connect to

To specify the user and password to use (when authentication is activated)

java -jar monsterDB.jar -u dave -pw password123

Connect and run a command

java -jar monsterDB.jar -d database -c collection -r "command"
Connect to the server, use the database and collection specified (collection is optional) and run the command, will return the result to stdout and stderr and return when completed. An example
java -jar monsterDB.jar -d newdb -r "db.fuzzy2.count({})"

Connected to localhost
Database is switched to newdb

{"Number":180000}

load a File

java -jar monsterDB.jar -h host -p port -u username -pw password -d aDatabase -c aCollection -f file -r recordType -o options

For more information follow the link below.

Commands Usage

Once connected, simply type help or help db, help collection or help load, each command is documented on the website here.

monsterDB> help

help db						-Database help
help load					-Data Loading help
help collection					-Collection commands help
listDatabaseNames				-List Databases
connect [host] [port] [username] [password]	-Connect/Reconnect session
use dbname					-Connect to a DB
drop dbname					-Drop a DB
create dbname					-Create a new DB
quit						-Leave

monsterDB> help load

loadJDBC collectionName connectionString SQLStatement [RecordType]		-Load a Collection from a JDBC Connection
loadFile collectionName filename/url RecordType {quote: "Quote Character to use",
 delimiter: "Delimiter ie ,|\t :",
 fileType: "Type ie csv,xls,xml,zip",
 httpheader: "Authentication Header",
 httpusername: "HTTP Site Username",
 httppassword: "Sites Password",
 rootNode: "XML root node name",
 encoding: "Character Encoding of File",
 sheetno: Number of sheet (0 based),
 extractPattern: "Wildcard pattern to extract from a zip",
 ftpusername: "FTP Site username",
 ftppassword: "FTP Site password"}		-Load a Collection from a file/url


monsterDB> help db

db listCollectionNames						-List Collections for current DB
db close							-Close current DB
db createCollection name					-Create new collection in DB
db createFuzzyCollection name definition.json ruleSetDir	-Create a fuzzy collection DB, using a definition file and a directory containing ruleset map files
db dropCollection name						-Drop a collection
db.collectionName.command()					-Run a command against the collectionName in the current DB

monsterDB> help collection

db.collectionName.deleteMany({filter: "value"})			-Delete Documents matching filter document
db.collectionName.find({filter: "value"})			-Find Documents matching filter document
db.collectionName.insertOne({....})				-Create new Documents