Enable Authentication in MongoDB

Follow below steps to enable authentication in MongoDB. 1- Run command praveen@acer-aspire:~# gedit /etc/mongodb.conf add ‘auth=true’ or uncomment by removing # it if exists. 2- Add atleast one user to the DB ‘admin’ . Admin user can access all the collections in the...

How to create MongoDB indexes ?

In simple words “indexes are used to speed up query performance”. Let’s say you have a query which takes around 120ms to execute without indexes i can assure you that with proper indexes you can reduce that time by at least 10 times. Let me show you...

How to delete MongoDB document ?

In this blog post i am going to explain how to delete MongoDB document. The are few ways which are illustrated below : If we execute remove on collection without any params then it will delete all records db.users.remove({}) // it will delete all documents along with...

How to drop a field from a MongoDb document ?

In this blog post we are going to see how to drop a field from a MongoDb document ? For people coming from RDBMS you must be remembering the alter table command for dropping/adding columns in a table. In MongoDB it is possible to do this operation on some of the...

Updating multiple documents in MongoDB

In this blog post we are going to learn the process of updating multiple documents in MongoDB. MongoDB provides us with update() function to achieve the same. Here are few use cases : db.users.find(); { "_id" : ObjectId("537da62d770359c2fb4668e2"),...

MongoDB : Difference between save and insert

MongoDB uses save and insert option for adding new records in the database. Let me explain the difference between two : Insert : insert is used to add a document in a mongodb collection Save : save is used to add as well as update a document in a mongodb collection....

Starting with Mongodb

– Mongodb is basically a database system that is document oriented and Nosql type. -Typically we call a table as a collection and a record as a document as oppose to tables and rows in RDBMS. -One of its advantage is that it does not restrict a us to a structure...

Installing and Configuring MongoDB

MongoDB is a NoSQL database that is cross platform and is a document-based system. It can be easily installed in an Ubuntu server from the command-line. In Ubuntu 12.04 LTS repositories it’s current version is 2.0.4. To install it in Debian / Ubuntu, open up a...

Working with MongoDB using Java

Hello guys, This is my first post on this blog. In this post i am going to explain how to interact with MongoDB using Java.First we need to install MongoDB using apt-get command in Ubuntu. Once we have installed MongoDB, we need a MongoDB jar file(Driver) which we...

MongoDB for MySQL Developers : Part 1

MongoDB for MySQL/RDBMS Developers : Part 1 This is my for first post for “Mongodb for Mysql developers series”. I come from RDBMS background and these were things which were new to me: MySQL - MongoDB "Database" - "Database"...