Skip to content

Wrapper for executing scripts from command line with MongoDB

License

Notifications You must be signed in to change notification settings

pveierland/mongoexec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mongoexec

Wrapper for executing scripts from command line with MongoDB.

Installation

Place mongoexec in a directory listed in your $PATH environment variable and make it executable, e.g:

sudo wget -O /usr/bin/mongoexec https://raw.githubusercontent.com/pveierland/mongoexec/master/mongoexec
sudo chmod +rx /usr/bin/mongoexec

Usage

Place a shebang at the start of the JavaScript file you wish to execute:

#!/usr/bin/mongoexec --quiet

The --quiet represents an optional argument which will be passed to the mongo executable. Positional arguments to the script can be passed on the command line, and will be available as the args array within the script. Keyword arguments to the script can also be passed on the command line and will be available as the given variable name within the script. Values will fall back to be parsed as strings, such that unquoted values can be used on the command line.

$ ./example.js 42 hi "Hello, World!" mykey=myvalue
args=[42,"hi","Hello, World!"]
mykey="myvalue"

License

CC0

About

Wrapper for executing scripts from command line with MongoDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published