Last active
December 17, 2015 17:09
-
-
Save piercemoore/5644400 to your computer and use it in GitHub Desktop.
Aliases for Shortcuts in MongoDB/Redis
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
### The commands | |
# Show all collections and the number of documents in each | |
mongo zngine_dev --eval "printjson(db.getCollectionNames().forEach(function(coll){printjson(coll+\"-\"+db[coll].count())}))" | |
# Drop all collections and remove all indexes from mongo | |
mongo zngine_dev --eval "db.getCollectionNames().forEach( function(coll) { if(coll!=\"system.indexes\") { db[coll].drop(); db[coll].dropIndexes(); } } )" | |
# Count all Redis keys | |
redis-cli keys "*" | wc -l | |
# Clear all Redis keys | |
redis-cli flushall | |
# Zngine-specific mongo queries | |
alias z_admins='mongo zngine_dev --eval "db.admins.find().limit(5).forEach(printjson)"' | |
alias z_owners='mongo zngine_dev --eval "db.owners.find().limit(5).forEach(printjson)"' | |
alias z_profiles='mongo zngine_dev --eval "db.profiles.find().limit(5).forEach(printjson)"' | |
### *Nix aliases for these commands | |
alias mongocount='mongo zngine_dev --eval "printjson(db.getCollectionNames().forEach(function(coll){printjson(coll+\"-\"+db[coll].count())}))"' | |
alias mongokill='mongo zngine_dev --eval "db.getCollectionNames().forEach( function(coll) { if(coll!=\"system.indexes\") { db[coll].drop(); db[coll].dropIndexes(); } } )" && mongocount' | |
alias rediscount='redis-cli keys "*" | wc -l' | |
alias rediskill='redis-cli flushall' | |
# Zngine-specific mongo queries | |
alias z_admins='mongo zngine_dev --eval "db.admins.find().limit(5).forEach(printjson)"' | |
alias z_owners='mongo zngine_dev --eval "db.owners.find().limit(5).forEach(printjson)"' | |
alias z_profiles='mongo zngine_dev --eval "db.profiles.find().limit(5).forEach(printjson)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment