valenciash
v0.3.0
Published
ValenciaDB Shell.
Readme
valenciash (ValenciaDB Shell and import/export tools)
Commands installed:
valenciash. ValenciaDB Shell.valenciaexp. ValenciaDB export tool.valenciaimp. ValenciaDB import tool.
Install
npm install -g valenciashvalenciash
valenciash is the ValenciaDB Shell, similar to the Node.js shell. We can print its help as follows:
valenciashTo connect to a database instance:
$ valenciash -e http://localhost:46000 -u root -p valencia
Connecting as root at http://localhost:46000...
root@http://localhost:46000>Once connected, you can use the .help command to print the internal commands:
root@http://localhost:46000> .help
.break Sometimes you get stuck, this gets you out
.clear Break, and also clear the local context
.db Print db object help
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
root@http://localhost:46000>db object
The db object/variable contains the entry point to use. Its help is printed with .db:
root@http://localhost:46000> .db
db.store.count() Number of documents.
db.store.exists(filter) Does document exist?
db.store.find(filter) Return document(s).
db.store.findAll() Return all documents.
db.store.findOne(filter) Return one document.
db.store.insert(doc) Insert a document.
db.store.remove(filter) Remove document(s).
db.store.replace(doc) Replace a document.
db.store.truncate() Remove all documents.
root@http://localhost:46000>Example of use:
root@http://localhost:46000> db.bands.findAll()
[ { pk: 'sad-lovers-and-giants', name: 'Sad Lovers & Giants' },
{ pk: 'the-chameleons', name: 'The Chameleons' } ]
root@http://localhost:46000>valenciexp
valenciaexp is the tool for exporting data. Its help can be printed as follows:
$ valenciaexpExporting data from stores
To export documents from user stores, we can use the valenciaexp data command. Help with:
$ valenciaexp dataExample:
$ valenciaexp data -e http://localhost:46000 -u root -p valencia -o bkDir --verbose 2
Connecting as root at http://localhost:46000...
Creating bkDir if needed...
Exporting db.bands to bkDir/bands.json...
Exporting db.albums to bkDir/albums.json...
Data export performed.
$If you want to export some stores, use the -l option. Example:
$ valenciaexp data -e http://localhost:46000 -u root -p valencia -l bands albums -o bkDir --verbose 2
Connecting as root at http://localhost:46000...
Creating bkDir if needed...
Exporting db.bands to bkDir/bands.json...
Exporting db.albums to bkDir/albums.json...
Data export performed.
$If you need to export system stores, use the -l option.
valenciaimp
valenciaimp is the tool for importing data. To print its help:
$ valenciaimpImporting data to stores
To import data to stores, we can use the valenciaimp data command. Help with:
$ valenciaimp dataExample:
$ valenciaimp data -e http://localhost:46000 -u root -p valencia -s bkDir --verbose 2 -t
Connecting as root at http://localhost:46000...
Reading bkDir...
Truncating db.albums...
Reading bkDir/albums.json...
Inserting 0 document(s) into db.albums...
Truncating db.bands...
Reading bkDir/bands.json...
Inserting 2 document(s) into db.bands...
Data import performed.
$Important. The stores must already exist.
