Tag Archives: MongoDB

Mongo Shell Console

Start mongo console:


Show databases:


Select a database:


Show selected database name:


Drop database:


Show collections in selected database


Select first 10 records from person_account collection:


Drop collection:


Insert a file in database mydata using mongofiles:


Files will be added to collections: fs.chunks and fs.files
List files:


Dump databse bikeshop in directory mongo_dump:


List records where uploadDate is greater than 26/10/2012:



Spring Data Mongo DB

Spring MVC Project with maven, mongodb, spring-data

This will contain only snippets of code. There are small dependencies that are not listed in these blocks of code.

I am running mongoDB in a remote Centos 6.2 Server.

Main Database is a PostgreSQL. Upper layers in MVC Service classes will try to fetch data from mongoDB. If is not available, will use SQL DB and update mongoDB. My application uses mongo for caching purposes and writes denormalized relationships in mongoDB.







A very simple entity:

A ultra simple Dao Repository:


Service class for Repository (contains JPA code for data transfer from JPA Repository to Mongo Repository, can be ignored):

Unit test for this implementation: