The document discusses MongoDB and Spring Data integration. It provides examples of creating, querying, and commenting on documents using Spring Data and MongoDB. It also covers topics like replication, sharding, and eventual consistency in MongoDB.
2. About Me
Solution Architect at 10gen (the company behind MongoDB)
- Previous Roles:
• EMEA Architect at SpringSource
• EMEA Principal JBoss Consultant at RedHat
22
13. Welcome to MongoDB News Dev
• User Story 1:
– As a user I should be able to create “News Articles”
• User Story 2:
– As a user I should be able to find a “News Articles” by Name
16. Welcome to MongoDB News Dev
• User Story 1:
– As a user I should be able to create “News Articles”
• User Story 2:
– As a user I should be able to find a “News Articles” by Name
• User Story 3:
– As a user I should be able to comment on “News Articles”
17. What is a Comment?
{
title: “What is new in 2.2 MongoDB”,
date : new Date(),
author : “Fred”
text : “.......”
tags : [“mongodb”, “nosql”]
comments : [
{author : “chris”, text: “this is great” , date : new Date()},
{author : “tom”, text: “rock on”, date : new Date()}
]
}
19. Welcome to MongoDB News Dev
• User Story 1:
– As a user I should be able to create “News Articles”
• User Story 2:
– As a user I should be able to find a “News Articles” by Name
• User Story 3:
– As a user I should be able to comment on “News Articles”
• User Story 4:
–As a user I want to know how many comments are on a “Articles”
20. What is a Comment?
{
title: “What is new in 2.2 MongoDB”,
....
comments : [
{author : “chris”, text: “this is great” , date : new Date()},
{author : “tom”, text: “rock on”, date : new Date()}
],
comments: count : 2
}
27. Replica Set
• Data Protection
• Multiple copies of the data
• Spread across Data Centers, AZs
• High Availability
• Automated Failover
• Automated Recovery
51. MongoDB Sharding
• Automatic partitioning and management
• Range based
• Convert to sharded system with no downtime
• Fully consistent
52. How mongoDB Sharding works
> db.runCommand({addshard: "shard1"});
> db.runCommand({shardCollection: "mydb.users",
key: {age: 1}})
-∞ +∞
• Range keys from -∞ to +∞
• Ranges are stored as "chunks"
53. How mongoDB Sharding works
> db.users.save({age: 40})
-∞ +∞
-∞ 40 41 +∞
• Data in inserted
• Ranges are split into more "chunks"