- How to create database in Mongo DB?
2.How to list all available database in Mongo DB?
- How to drop database in Mongo DB?
- How to create collection in Mongo DB?
Name:String:Name of the collection to be created
Options:Document (Optional): Specify options about memory size and indexing
Options can be capped,autoIndexID,size or max.
5.how to list collections ?
- how to drop a collection in Mongo DB?
drop() method will return true, if the selected collection is dropped successfully otherwise it will return false
What all are the data types used in Mongo DB?
String,Integer,Boolean,Double,Min/Max keys,Arrays,timestamp,Object,symbol,date,code,binary data and regular expression
8.How to insert document to Mongo DB collection?
To insert data into MongoDB collection, insert() or save()method is normally used.
- How to query document in Mongo DB?
To query data from MongoDB collection, find() method is used.
Find() display document in unstructured way and Pretty() is used to display results in formatted way
10.How to Update document in Mongo DB?
update() and save() methods are used to update document into a collection.
- How to delete document from Mongo DB?
remove() method is used to remove document from the collection. remove() method accepts two parameters. One is deletion criteria and second is justOne flag
1.deletion criteria : (Optional) deletion criteria according to documents will be removed.
2.justOne : (Optional) if set to true or 1, then remove only one document.
What is projection in Mongo Db?
In mongodb projection meaning is selecting only necessary data rather than selecting whole of the data of a document
13.How to limit no of records in Mongo DB?
limit() method is used to retrieve limited documents. limit() method accepts one number type argument, which is number of documents that you want to displayed
14.How to retrieve sorted documents from Mongo DB?
sort() method. sort() method accepts a document containing list of fields along with their sorting order.
1 and -1 are used. 1 is used for ascending order while -1 is used for descending order.
15.What is indexing in Mongo DB and how to create Index in Mongo DB?
To scan the documents faster in Mongo DB we need to create indexing.
ensureIndex() method is used to create index in Mongo DB.
16.What is aggregation in MongoDB?
Aggregations operations process data documents and return computed results
aggregate() is used.
17.What is Replication in Mongo DB and how it helps?
i)Synchronizing data in multiple servers
ii)To keep data safe
iii) High availability of data
v)no maintenance outage
- what is sharding in Mongo DB and why sharding?
Sharding is the process of storing data records across multiple machines
i)In replication all writes go to master node
ii)Latency sensitive queries still go to master
iii)Single replica set has limitation of 12 nodes
iv)Memory can’t be large enough when active dataset is big
v)Local Disk is not big enough
vi)Vertical scaling is too expensive
19.How to create backup in Mongo DB?
mongodump is used to create backup.
This command will dump all data of your server into dump directory
20.What all are the commands used to monitor deployment in Mongo DB?
mongostat :This command checks the status of all running mongod instances and return counters of database operations. counters is on inserts,updates,deletes etc
mongotop : This command track and report the read and write activity of MongoDB instance on a collection basis
© 2015, www.techkatak.com. All rights reserved.