Mongo shell
mongo : executable.
Flags :
–eval « javascript code »
Mongo shell commands
Switch db:
use foodb
Find all elements in default collection :
db.myCollection.find()
Command mixing linux shell and mongo shell to insert :
for v in $(seq 1 100); do export dd=$(date); mongo --eval "var xx='${dd}'; db.myCollection.insertOne( { 'toto': 100, 'tutu': xx } )"; sleep 1s ; done |