You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Export Mongo DB collection to a JSON file: mongoexport --db=DB_NAME --collection=COLLECTION_NAME --out=data.json
Export specific fields from a Mongo DB collection to a JSON file: mongoexport --db=DB_NAME --fields=FIELD_NAME,FIELD_NAME2 --collection=COLLECTION_NAME --out=data.json
Aggregations
Count the number of documents: db.accounts.aggregate([ { "$count": "number of documents" }])
Show only the sub element 'attachment_uuids': db.accounts.aggregate( [ {$project: {"hosts.attachment_uuids": 1, _id:0}} ] )
Users
Display users:
use admin
db.getUsers()
Create administrative user
use admin
db.createUser({user: "admin", pwd: "some_password", roles: ["root"]})