690 shaares
3 liens privés
3 liens privés
3 résultats
taggé
mongo
Execute mongo command in bash (mongo-client package must be installed)
echo "db.reports.drop();" | mongo -u <username> -p <passwors> <mydatabase> --authenticationDatabase admin
Find by id :
db.test.find({"_id" : ObjectId("4ecc05e55dd98a436ddcc47c")})
Show all ids :
var a = db.c.find({}, {_id:1}).map(function(item){ return item._id; })
Run actions on elements :
tests.forEach(function(test) {
if (evaluation.hasOwnProperty('toto')) {
print('toto was here');
} else {
db.tests.save(test);
}
});
Run javascript :
load('/tmp/xxx.js');
Connect to database :
db = connect("mongodb://user:password@localhost:27017/lcri?authSource=admin");
Petit tutoriel éclairé sur l'init d'une base mongo sous docker