Created
July 30, 2014 09:19
-
-
Save jaymecd/ceeff79ebabe8741162e to your computer and use it in GitHub Desktop.
Simple CLI MongoDb query runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOST="localhost" | |
DB="test" | |
QUERY="${1}" | |
if [ "x${QUERY}" == "x" ]; then | |
read -p "Query: " QUERY | |
fi | |
if [ "x${QUERY}" == "x" ]; then | |
echo " Aborted. No query to process..." | |
exit | |
fi | |
time mongo "${HOST}/${DB}" --quiet --eval "var res = ${QUERY}; shellPrint(res)" | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment