MongoDB

From Wasya Wiki
Revision as of 00:50, 1 January 2018 by Piousbox (Talk | contribs)

Jump to: navigation, search

Install MongoDB on ubuntu

From: https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update -y
sudo apt-get install -y mongodb-org

Count Documents

db.collection.aggregate(
  [
    { $group: { _id: null, count: { $sum: 1 } } }
  ]
)

Performance Tuning

db.getProfilingStatus()
db.getProfilingLevel()
db.setProfilingLevel(1, 10)
db.getCollection('system.profile').find({})