MongoDB

From Wasya Wiki
Revision as of 19:40, 5 September 2017 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 } } }
  ]
)