Skip to content

Latest commit

 

History

History
 
 

livelessons-data-mongodb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Lesson 4: Working With Data (MongoDB)

Introduction

This example shows how you can use the MongoDB document store.

Building and running the sample

Use the following commands to build run the application:

$ mvn clean package
$ java -jar target/livelessons-data-mongodb-1.0.0-SNAPSHOT.jar

Understanding the code

The same domain to the JPA sample is used with this demo. Rather than being a @Entity the Car here is a @Document. It has also been updated with a position (the geo-location where the car is stored).

The CarRepository works in the same way as any Spring Data repository and has the familiar findByMakeIgnoringCase method. The demo also includes a findByPositionNear method which shows how you can use MongoDB’s geo features.

The DataMongoDBApplication show how queries are executed and how you can also use MongoDB’s GridFS to store blob data.