MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document. This article lists about the frequently used commands of MongoDB used by developers and DBA in their day to day development and operation life.
MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document. This article lists about the frequently used commands of MongoDB used by developers and DBA in their day to day development and operation life.
show dbs print a list of all databases on the server use myTestDB create new database "myTestDB" db know your current selected database db.dropDatabase() drop the current selected database db.createCollection("Employee") create new collection "Employee" show collections print a list of all collections created db.Employee.drop() drop the collection "Employee" db.Employee.insert({name: 'Raj', address: insert document in collection "Employee" 'Bangalore'}) db.Employee.find() list the documents in collection "Employee"
db.getUsers(); list down all the users of current database
show roles list down all the roles
db.Employee.dataSize() get the size of the collection "Employee" db.Employee.storageSize() get the total size of document stored in the collection "Employee" db.Employee.totalSize() get the total size in bytes for both collection data and indexes
db.Employee.totalIndexSize() get the total size of all indexes in the