Created
May 20, 2015 05:43
-
-
Save todvora/27a3b7055e464eef1439 to your computer and use it in GitHub Desktop.
Variety.js - analyze all available collections
This file contains hidden or 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
#!/usr/bin/env bash | |
# the database name, that will be analyzed | |
DATABASE_NAME="test" | |
# read all collection names, using mongo shell | |
COLLECTIONS=$(mongo $DATABASE_NAME --eval "db.getCollectionNames().join('\n');" --quiet) | |
echo -e "Found collections: \n$COLLECTIONS" | |
# iterate over the collection names | |
while read -r collection; do | |
echo | |
echo "Collection '$collection':" | |
# analyze every collection, no other options specified. Output is set to --quiet, no debug info will be printed, | |
# only ascii table with the analysis. | |
mongo $DATABASE_NAME --quiet --eval "var collection = '$collection'" variety.js | |
echo | |
done <<< "$COLLECTIONS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment