Category Archives: MongoDB

MongoDB -Get Size, RowCount, CollectionSize

There are two different ways of getting the desired result The first method is iterating through each collection using for loop and displaying the result cols = db.getCollectionNames(); for (index = 0; index < cols.length; index++) { var coll = … Continue reading

Posted in MongoDB | Tagged , , | Leave a comment

MongoDB – Local and Remote Connections in Mongo Shell

To Install and Getting started with MongoDB refer the below links Getting Started with MongoDB Install MongoDB 3.2 on Windows Installation Guide How to access Mongo instance Open a terminal session or command window. For a local connection to mongod, … Continue reading

Posted in MongoDB | Tagged , , | Leave a comment

MongoDB -Calculating Collection Size

Calculating Collection Size We can get the size of a collections by using the shell’s functions db.collection.dataSize() : Returns data size in bytes for the collection. db.collection.storageSize() : Returns allocation size in bytes, including unused space. db.collection.totalSize() : Returns the data size plus … Continue reading

Posted in MongoDB | Tagged , , , , | Leave a comment

MongoDB – Calculating Document Size

We can get the size of a document is by using the shell’s Object.bsonsize() function. We pass the object_id of the document to get the size For example in the foo collection, we can find the size of the document using any … Continue reading

Posted in MongoDB | Tagged | Leave a comment

MongoDB -Access different databases and Collections

You can use db.getSiblingDB() method to access another database without switching the database. To List Collections of PP database and query collection named “restaurants” db.getSiblingDB(‘PP’).getCollectionNames() The PP Database has three collections first restaurants second Accessing PP database temporarily from Test … Continue reading

Posted in MongoDB | Tagged , , , , , , | Leave a comment

Install MongoDB 3.2 on Windows

We can install MongoDB as a windows service. The steps are given below Prerequisite – Install Hotfix kb2731284 on the MongoDB Server on Windows Box STEP1 – Download MongoDB Download the latest release of MongoDB from http://www.mongodb.org/downloads and select the … Continue reading

Posted in MongoDB | Tagged , | 2 Comments