SlideShare a Scribd company logo
MongoDB: ObjStorSol + Des+Map’nYeah, I shortened that… but not to OSSDnM
…AppServer - J2EE (JBoss, Resin)Hosted AppServices - Google AppEngineDatastore - Objectify (GAEJ ORM/ODM)MongoDB – Morphia (ODM)Community Developer (and more)How I got here…
Basic ExpectationsNo transactions (but atomic updates)Memory mapped data filesDocument storeFast-N-Loose by default (no safe/w/GLE)Indexing order matters; query optimizer helpsOne writer (serialized writes)One JS thread (M/R, $where, group)Many query threads (non-js)BSON everywhere
What is the shell?
What is it good for?DebuggingTestingAdministrationScripting GlueNot building apps, probably…
Shell Demo
Single Collection, InheritanceOne – ManyEmbeddedReferenceOn the one -> Array of refsOn the Many -> Add a ref fieldTreesMany – ManyProb. best to store on only one side.Designs
{        _id : "scotthernandez",        name : "Scott Hernandez",desc : "that guy",        groups : [                "users",                "admins",                "fishermen"        ]}People - Groups
{        "_id" : "users",        "desc" : "normal users“ },{        "_id" : "fishermen",        "desc" : "people who fish“ },{        "_id" : "admins",        "privledges" : 2,        "desc" : "administrative users“ }Group - People
blog =: { text: “I like to swim”, author: “scott”,	comments: [		{author:”ralph”, text:”me2”, 		replies:[		   {author:”liz”, text:”doesn’t every1?”}		]},		{author:”jeff”, text:”good to know”}	],ts:Date(…)}Tree
Raw MongoDB DriverMap<String, Object> view of objectsRough but dynamicMorphia (type-safe mapper)POJOsAnnotation based (similar to JPA)Syntactic sugar and helpersOthersCode generators, other jvm languagesJava Library Choices
BSON PackageTypesEncode/DecodeDBObject (Map<String, Object>)Nested MapsDirectly encoded to binary format (BSON)MongoDB PackageMongoDBObject (BasicDBObject/Builder)DB/DBColletionDBQuery/DBCursorMongoDB Java Driver
Data Typesint and longArray/ArrayListStringbyte[] – binDataDouble (IEEE 754 FP)Date (ms since epoch UTC)NullBooleanJavaScript StringRegexObjectId (ts(4)+ host(3) + pid(2)+ incr(3) ) 12-byteBSON Package
Morphia: MongoDB MapperMaps POJOType-safeAccess Patterns: DAO/Datastore/RollYourOwnData TypesLow performance overheadJPA likeMany concepts came from Objectify (GAE)
Annotations@Entity(“collectionName”)@Id@Transient (not transient)@Indexed(…)@Property(“fieldAlias”)@AlsoLoad({aliases})@Reference@Serialized[@Embedded]
Lifecycle Events@PrePersist@PreSave@PostPersist@PreLoad@PostLoadEntityListenersEntityInterceptor
Datastore Basicsget(class, id)find(class, […])save(entity, […])delete(query)getCount(query)update/First(query, upOps)findAndModify/Delete(query, upOps)
Basic POJO@Entityclass Person {	@Id ObjectId name;SexEnum sex;@IndexedInteger height;}
QueriesDatastoreds = …Query q = ds.createQuery(Person.class);q.field(“height”).greaterThan(155).limit(5);for(Person p : q.fetch())   print(p);Person me = q.field(“name”).startsWith(“sc”).get();
Save whole object graphs (get/save)Update parts (embedded objects)Un/set fieldsPush/pop arrays (lists)Increment numeric fieldsAny combination of the aboveGet/Save or Update
Update Operationsset(field, val)unset(field)inc(field, [val])dec(field)add(field, val)addAdd(field, vals)removeFirst/Last(field)removeAll(field, vals)
Update existing propsUpdate w/new propsExamples
UpdateDatastoreds = …Query q = ds.find(Person.class, “name”, “scott”);UpdateOperationuo = ds.createUpdateOperations(cls)uo.set(“city”, “seattle”).set(“lastUpdated”, new Date());UpdateResults res = ds.update(q, uo);if(res.getUpdatedCount() > 0)  //do something?
Morphia Relationships Annotations[@Embedded]Load/Save with EntityUpdate@ReferenceStored as DBRef(s)Loaded with EntityNot automatically savedKey<T>Stored as DBRef(s)Just a link, but resolvable by Datastore/Query
Or… ScottHernandez@gmail.comQuestions?

More Related Content

What's hot (20)

PDF
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
PPTX
Social Analytics with MongoDB
Patrick Stokes
 
PPT
Meetup#1: 10 reasons to fall in love with MongoDB
Minsk MongoDB User Group
 
PDF
Mongophilly shell-2011-04-26
kreuter
 
PPT
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
PPTX
Back to Basics Webinar 3 - Thinking in Documents
Joe Drumgoole
 
PDF
Mongo Presentation by Metatagg Solutions
Metatagg Solutions
 
PPT
PhpstudyTokyo MongoDB PHP CakePHP
ichikaway
 
ODP
MongoDB : The Definitive Guide
Wildan Maulana
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
PDF
CouchDB in The Room
Makoto Ohnami
 
PPTX
Back to Basics Webinar 1 - Introduction to NoSQL
Joe Drumgoole
 
PDF
Intro To MongoDB
Alex Sharp
 
PPT
Mongo-Drupal
Forest Mars
 
PPTX
MongoDB 101
Abhijeet Vaikar
 
KEY
MongoDB
Steven Francia
 
ODP
Django with MongoDB using MongoEngine
Rakesh Kumar
 
PPTX
Introduction to MongoDB
Hossein Boustani
 
KEY
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
PDF
Mastering the MongoDB Shell
MongoDB
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
Social Analytics with MongoDB
Patrick Stokes
 
Meetup#1: 10 reasons to fall in love with MongoDB
Minsk MongoDB User Group
 
Mongophilly shell-2011-04-26
kreuter
 
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
Back to Basics Webinar 3 - Thinking in Documents
Joe Drumgoole
 
Mongo Presentation by Metatagg Solutions
Metatagg Solutions
 
PhpstudyTokyo MongoDB PHP CakePHP
ichikaway
 
MongoDB : The Definitive Guide
Wildan Maulana
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
CouchDB in The Room
Makoto Ohnami
 
Back to Basics Webinar 1 - Introduction to NoSQL
Joe Drumgoole
 
Intro To MongoDB
Alex Sharp
 
Mongo-Drupal
Forest Mars
 
MongoDB 101
Abhijeet Vaikar
 
Django with MongoDB using MongoEngine
Rakesh Kumar
 
Introduction to MongoDB
Hossein Boustani
 
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
Mastering the MongoDB Shell
MongoDB
 

Similar to MongoDB Aug2010 SF Meetup (20)

KEY
Mongodb intro
christkv
 
ODP
DrupalCon Chicago Practical MongoDB and Drupal
Doug Green
 
PPTX
Intro To Mongo Db
chriskite
 
PDF
Mongo db japan
rogerbodamer
 
PDF
mongodb-introduction
Tse-Ching Ho
 
KEY
Mongo NYC PHP Development
Fitz Agard
 
PDF
MongoDB at FrozenRails
Mike Dirolf
 
PDF
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PPT
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Rick Copeland
 
PPT
Mongodb Training Tutorial in Bangalore
rajkamaltibacademy
 
KEY
NoSQL: Why, When, and How
BigBlueHat
 
PPT
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rick Copeland
 
PPTX
MongoDB
nikhil2807
 
PPT
mongodb-120401144140-phpapp01 claud camputing
moeincanada007
 
KEY
Practical Use of MongoDB for Node.js
async_io
 
PPTX
Mongo db present
scottmsims
 
PPTX
Python mongo db-training-europython-2011
Andreas Jung
 
KEY
MongoDB - Ruby document store that doesn't rhyme with ouch
Wynn Netherland
 
PDF
Building your first app with mongo db
MongoDB
 
Mongodb intro
christkv
 
DrupalCon Chicago Practical MongoDB and Drupal
Doug Green
 
Intro To Mongo Db
chriskite
 
Mongo db japan
rogerbodamer
 
mongodb-introduction
Tse-Ching Ho
 
Mongo NYC PHP Development
Fitz Agard
 
MongoDB at FrozenRails
Mike Dirolf
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
Building your first app with MongoDB
Norberto Leite
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Rick Copeland
 
Mongodb Training Tutorial in Bangalore
rajkamaltibacademy
 
NoSQL: Why, When, and How
BigBlueHat
 
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rick Copeland
 
MongoDB
nikhil2807
 
mongodb-120401144140-phpapp01 claud camputing
moeincanada007
 
Practical Use of MongoDB for Node.js
async_io
 
Mongo db present
scottmsims
 
Python mongo db-training-europython-2011
Andreas Jung
 
MongoDB - Ruby document store that doesn't rhyme with ouch
Wynn Netherland
 
Building your first app with mongo db
MongoDB
 
Ad

More from Scott Hernandez (14)

PPTX
MongoDB 2.8 Replication Internals: Fitting it all together
Scott Hernandez
 
PDF
Advanced Replication Internals
Scott Hernandez
 
PPTX
Realtime Analytics with MongoDB Counters (mongonyc 2012)
Scott Hernandez
 
PDF
MongoDB Operational Best Practices (mongosf2012)
Scott Hernandez
 
PDF
MongoDB Datacenter Awareness (mongosf2012)
Scott Hernandez
 
PPTX
Mongo sf easy java persistence
Scott Hernandez
 
PPTX
MongoDB: Easy Java Persistence with Morphia
Scott Hernandez
 
PPTX
MongoDB: Mastering the shell
Scott Hernandez
 
PPTX
MongoDB: Backup, Restore, and DR
Scott Hernandez
 
PPT
A Brief MongoDB Intro
Scott Hernandez
 
PPTX
What's new in the MongoDB Java Driver (2.5)?
Scott Hernandez
 
PPTX
MongoDB: tips, trick and hacks
Scott Hernandez
 
PPTX
Mastering the MongoDB Javascript Shell
Scott Hernandez
 
PPTX
Java Development with MongoDB
Scott Hernandez
 
MongoDB 2.8 Replication Internals: Fitting it all together
Scott Hernandez
 
Advanced Replication Internals
Scott Hernandez
 
Realtime Analytics with MongoDB Counters (mongonyc 2012)
Scott Hernandez
 
MongoDB Operational Best Practices (mongosf2012)
Scott Hernandez
 
MongoDB Datacenter Awareness (mongosf2012)
Scott Hernandez
 
Mongo sf easy java persistence
Scott Hernandez
 
MongoDB: Easy Java Persistence with Morphia
Scott Hernandez
 
MongoDB: Mastering the shell
Scott Hernandez
 
MongoDB: Backup, Restore, and DR
Scott Hernandez
 
A Brief MongoDB Intro
Scott Hernandez
 
What's new in the MongoDB Java Driver (2.5)?
Scott Hernandez
 
MongoDB: tips, trick and hacks
Scott Hernandez
 
Mastering the MongoDB Javascript Shell
Scott Hernandez
 
Java Development with MongoDB
Scott Hernandez
 
Ad

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

MongoDB Aug2010 SF Meetup