MongoDB Workshop
Sophia Conf 2018
4
Document Model
{
first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type : ‘Point’,
coordinates : [45.123,47.232]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
]
}
MongoDB
RDBMS
5
Developer Agility - Documents
{
first_name: ‘Paul’,
surname: ‘Miller’,
ID: 125678,
city: ‘London’,
location: {
type : ‘Point’,
coordinates : [45.123,47.232]
},
Profession: [‘banking’, ‘finance’, ‘trader’],
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
]
}
Fields can contain an array
of sub-documents
Typed field values
Fields can contain
arrays
String
Number
Geo-Location
Fields
6
Developer Agility – Flexible Schema
{
product_name: ‘Acme Paint’,
sku: "123-567-845",
color: [‘Red’, ‘Green’],
size_oz: [8, 32],
finish: [‘satin’, ‘eggshell’]
}
{
product_name: ‘T-shirt’,
sku : "123-589-234",
size: [‘S’, ‘M’, ‘L’, ‘XL’],
color: [‘Heather Gray’ … ],
material: ‘100% cotton’,
wash: ‘cold’,
dry: ‘tumble dry low’
}
{
product_name: ‘Mountain Bike’,
sku : "143-534-678",
brake_style: ‘mechanical disc’,
color: ‘grey’,
frame_material: ‘aluminum’,
no_speeds: 21,
package_height: ‘7.5x32.9x55’,
weight_lbs: 44.05,
suspension_type: ‘dual’,
wheel_size_in: 26
}
7
Developer Agility – Use Your Favourites
Page 7
Morphia
MEAN Stack
8
Replica Set
SecondarySecondary
Primary
9
Sharded Cluster
Application
mongos mongos mongos
Driver
Config Server
11
Atlas - Database as a Service
Self-service, elastic,
and automated
Secure by defaultGlobal and highly
available
Continuous
backups
Real-time monitoring and
optimization
Cloud agnostic
12
Demo!
13
Workshop
● Download & install MongoDB 4.0.0
export PATH="$PATH:/home/polux/Softwares/mongodb-linux-x86_64-enterprise-debian92-4.0.0/bin"
● Start a simple node
mkdir data
mongod --dbpath data
● Import simple dataset
https://github.com/MaBeuLux88/mongodb-json-files
mongoimport --drop -d test -c grades grades.json
● Scripts to start a ReplicaSet and a Sharded Cluster
https://github.com/MaBeuLux88/MongoDB-Training
● Free ReplicaSet in MongoDB Atlas
https://cloud.mongodb.com
● Download, install and test MongoDB Compass
● Make a simple Hello World with the driver of your choice with MongoDB Atlas or localhost node
● Make some CRUD operations and discover the driver API
● Create a small program to listen a change streams
● Check you can listen the CRUD operations with your change stream
14
Conclusion
@MBeugnet MaBeuLux88
15
Community is awesome!
https://mongo-db.slack.com
https://mongodb.influitive.com/
16
MongoDB Events
MongoDB .local Paris
TOO
LATE
MongoDB Workshop Sophia Conf 2018

MongoDB Workshop Sophia Conf 2018

  • 2.
  • 4.
    4 Document Model { first_name: ‘Paul’, surname:‘Miller’, city: ‘London’, location: { type : ‘Point’, coordinates : [45.123,47.232] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } MongoDB RDBMS
  • 5.
    5 Developer Agility -Documents { first_name: ‘Paul’, surname: ‘Miller’, ID: 125678, city: ‘London’, location: { type : ‘Point’, coordinates : [45.123,47.232] }, Profession: [‘banking’, ‘finance’, ‘trader’], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Fields can contain an array of sub-documents Typed field values Fields can contain arrays String Number Geo-Location Fields
  • 6.
    6 Developer Agility –Flexible Schema { product_name: ‘Acme Paint’, sku: "123-567-845", color: [‘Red’, ‘Green’], size_oz: [8, 32], finish: [‘satin’, ‘eggshell’] } { product_name: ‘T-shirt’, sku : "123-589-234", size: [‘S’, ‘M’, ‘L’, ‘XL’], color: [‘Heather Gray’ … ], material: ‘100% cotton’, wash: ‘cold’, dry: ‘tumble dry low’ } { product_name: ‘Mountain Bike’, sku : "143-534-678", brake_style: ‘mechanical disc’, color: ‘grey’, frame_material: ‘aluminum’, no_speeds: 21, package_height: ‘7.5x32.9x55’, weight_lbs: 44.05, suspension_type: ‘dual’, wheel_size_in: 26 }
  • 7.
    7 Developer Agility –Use Your Favourites Page 7 Morphia MEAN Stack
  • 8.
  • 9.
  • 11.
    11 Atlas - Databaseas a Service Self-service, elastic, and automated Secure by defaultGlobal and highly available Continuous backups Real-time monitoring and optimization Cloud agnostic
  • 12.
  • 13.
    13 Workshop ● Download &install MongoDB 4.0.0 export PATH="$PATH:/home/polux/Softwares/mongodb-linux-x86_64-enterprise-debian92-4.0.0/bin" ● Start a simple node mkdir data mongod --dbpath data ● Import simple dataset https://github.com/MaBeuLux88/mongodb-json-files mongoimport --drop -d test -c grades grades.json ● Scripts to start a ReplicaSet and a Sharded Cluster https://github.com/MaBeuLux88/MongoDB-Training ● Free ReplicaSet in MongoDB Atlas https://cloud.mongodb.com ● Download, install and test MongoDB Compass ● Make a simple Hello World with the driver of your choice with MongoDB Atlas or localhost node ● Make some CRUD operations and discover the driver API ● Create a small program to listen a change streams ● Check you can listen the CRUD operations with your change stream
  • 14.
  • 15.
  • 16.