SlideShare ist ein Scribd-Unternehmen logo
1 von 25
MongoDB: ObjStorSol + Des+Map’n Yeah, I shortened that… but not to OSSDnM
… AppServer - J2EE (JBoss, Resin) Hosted AppServices - Google AppEngine Datastore - Objectify (GAEJ ORM/ODM) MongoDB – Morphia (ODM) Community Developer (and more) How I got here…
Basic Expectations No transactions (but atomic updates) Memory mapped data files Document store Fast-N-Loose by default (no safe/w/GLE) Indexing order matters; query optimizer helps One 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? Debugging Testing Administration Scripting Glue Not building apps, probably…
Shell Demo
Single Collection, Inheritance One – Many Embedded Reference On the one -> Array of refs On the Many -> Add a ref field Trees Many – Many Prob. 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 Driver Map<String, Object> view of objects Rough but dynamic Morphia (type-safe mapper) POJOs Annotation based (similar to JPA) Syntactic sugar and helpers Others Code generators, other jvm languages Java Library Choices
BSON Package Types Encode/Decode DBObject (Map<String, Object>) Nested Maps Directly encoded to binary format (BSON) MongoDB Package Mongo DBObject (BasicDBObject/Builder) DB/DBColletion DBQuery/DBCursor MongoDB Java Driver
Data Types int and long Array/ArrayList String byte[] – binData Double (IEEE 754 FP) Date (ms since epoch UTC) Null Boolean JavaScript String Regex ObjectId (ts(4)+ host(3) + pid(2)+ incr(3) ) 12-byte BSON Package
Morphia: MongoDB Mapper Maps POJO Type-safe Access Patterns: DAO/Datastore/RollYourOwn Data Types Low performance overhead JPA like Many 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 @PostLoad EntityListeners EntityInterceptor
Datastore Basics get(class, id) find(class, […]) save(entity, […]) delete(query) getCount(query) update/First(query, upOps) findAndModify/Delete(query, upOps)
Basic POJO @Entity class Person { 	@Id  ObjectId name; SexEnum sex; @Indexed Integer height; }
Queries Datastoreds = … 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 fields Push/pop arrays (lists) Increment numeric fields Any combination of the above Get/Save or Update
Update Operations set(field, val) unset(field) inc(field, [val]) dec(field) add(field, val) addAdd(field, vals) removeFirst/Last(field) removeAll(field, vals)
Update existing props Update w/new props Examples
Update Datastoreds = … 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 Entity Update @Reference Stored as DBRef(s) Loaded with Entity Not automatically saved Key<T> Stored as DBRef(s) Just a link, but resolvable by Datastore/Query
Or… ScottHernandez@gmail.com Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Social Analytics with MongoDB
Social Analytics with MongoDBSocial Analytics with MongoDB
Social Analytics with MongoDB
Patrick Stokes
 
Meetup#1: 10 reasons to fall in love with MongoDB
Meetup#1: 10 reasons to fall in love with MongoDBMeetup#1: 10 reasons to fall in love with MongoDB
Meetup#1: 10 reasons to fall in love with MongoDB
Minsk MongoDB User Group
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
Wildan Maulana
 

Was ist angesagt? (20)

Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
 
Social Analytics with MongoDB
Social Analytics with MongoDBSocial Analytics with MongoDB
Social Analytics with MongoDB
 
Meetup#1: 10 reasons to fall in love with MongoDB
Meetup#1: 10 reasons to fall in love with MongoDBMeetup#1: 10 reasons to fall in love with MongoDB
Meetup#1: 10 reasons to fall in love with MongoDB
 
Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26
 
Building Your First MongoDB App ~ Metadata Catalog
Building Your First MongoDB App ~ Metadata CatalogBuilding Your First MongoDB App ~ Metadata Catalog
Building Your First MongoDB App ~ Metadata Catalog
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
Mongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg Solutions
 
PhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHPPhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHP
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The Room
 
Back to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQLBack to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQL
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDB
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
MongoDB
MongoDBMongoDB
MongoDB
 
Django with MongoDB using MongoEngine
Django with MongoDB using MongoEngineDjango with MongoDB using MongoEngine
Django with MongoDB using MongoEngine
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB Shell
 

Ähnlich wie MongoDB Aug2010 SF Meetup

Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
chriskite
 
Mongo NYC PHP Development
Mongo NYC PHP Development Mongo NYC PHP Development
Mongo NYC PHP Development
Fitz Agard
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
BigBlueHat
 
mongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputingmongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputing
moeincanada007
 

Ähnlich wie MongoDB Aug2010 SF Meetup (20)

Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 
Mongo db japan
Mongo db japanMongo db japan
Mongo db japan
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
Mongo NYC PHP Development
Mongo NYC PHP Development Mongo NYC PHP Development
Mongo NYC PHP Development
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForge
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalore
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
 
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and PythonRapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and Python
 
MongoDB
MongoDBMongoDB
MongoDB
 
mongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputingmongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputing
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Mongo db present
Mongo db presentMongo db present
Mongo db present
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouch
 
Building your first app with mongo db
Building your first app with mongo dbBuilding your first app with mongo db
Building your first app with mongo db
 

Mehr von Scott Hernandez

Mongo sf easy java persistence
Mongo sf   easy java persistenceMongo sf   easy java persistence
Mongo sf easy java persistence
Scott Hernandez
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
Scott Hernandez
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
Scott Hernandez
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
Scott Hernandez
 

Mehr von Scott Hernandez (14)

MongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all togetherMongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all together
 
Advanced Replication Internals
Advanced Replication InternalsAdvanced Replication Internals
Advanced Replication Internals
 
Realtime Analytics with MongoDB Counters (mongonyc 2012)
Realtime Analytics with MongoDB Counters (mongonyc 2012)Realtime Analytics with MongoDB Counters (mongonyc 2012)
Realtime Analytics with MongoDB Counters (mongonyc 2012)
 
MongoDB Operational Best Practices (mongosf2012)
MongoDB Operational Best Practices (mongosf2012)MongoDB Operational Best Practices (mongosf2012)
MongoDB Operational Best Practices (mongosf2012)
 
MongoDB Datacenter Awareness (mongosf2012)
MongoDB Datacenter Awareness (mongosf2012)MongoDB Datacenter Awareness (mongosf2012)
MongoDB Datacenter Awareness (mongosf2012)
 
Mongo sf easy java persistence
Mongo sf   easy java persistenceMongo sf   easy java persistence
Mongo sf easy java persistence
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
MongoDB: Mastering the shell
MongoDB: Mastering the shellMongoDB: Mastering the shell
MongoDB: Mastering the shell
 
MongoDB: Backup, Restore, and DR
MongoDB: Backup, Restore, and DRMongoDB: Backup, Restore, and DR
MongoDB: Backup, Restore, and DR
 
A Brief MongoDB Intro
A Brief MongoDB IntroA Brief MongoDB Intro
A Brief MongoDB Intro
 
What's new in the MongoDB Java Driver (2.5)?
What's new in the MongoDB Java Driver (2.5)?What's new in the MongoDB Java Driver (2.5)?
What's new in the MongoDB Java Driver (2.5)?
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

MongoDB Aug2010 SF Meetup

  • 1. MongoDB: ObjStorSol + Des+Map’n Yeah, I shortened that… but not to OSSDnM
  • 2. … AppServer - J2EE (JBoss, Resin) Hosted AppServices - Google AppEngine Datastore - Objectify (GAEJ ORM/ODM) MongoDB – Morphia (ODM) Community Developer (and more) How I got here…
  • 3. Basic Expectations No transactions (but atomic updates) Memory mapped data files Document store Fast-N-Loose by default (no safe/w/GLE) Indexing order matters; query optimizer helps One writer (serialized writes) One JS thread (M/R, $where, group) Many query threads (non-js) BSON everywhere
  • 4. What is the shell?
  • 5. What is it good for? Debugging Testing Administration Scripting Glue Not building apps, probably…
  • 7. Single Collection, Inheritance One – Many Embedded Reference On the one -> Array of refs On the Many -> Add a ref field Trees Many – Many Prob. best to store on only one side. Designs
  • 8. { _id : "scotthernandez", name : "Scott Hernandez", desc : "that guy", groups : [ "users", "admins", "fishermen" ] } People - Groups
  • 9. { "_id" : "users", "desc" : "normal users“ }, { "_id" : "fishermen", "desc" : "people who fish“ }, { "_id" : "admins", "privledges" : 2, "desc" : "administrative users“ } Group - People
  • 10. 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
  • 11. Raw MongoDB Driver Map<String, Object> view of objects Rough but dynamic Morphia (type-safe mapper) POJOs Annotation based (similar to JPA) Syntactic sugar and helpers Others Code generators, other jvm languages Java Library Choices
  • 12. BSON Package Types Encode/Decode DBObject (Map<String, Object>) Nested Maps Directly encoded to binary format (BSON) MongoDB Package Mongo DBObject (BasicDBObject/Builder) DB/DBColletion DBQuery/DBCursor MongoDB Java Driver
  • 13. Data Types int and long Array/ArrayList String byte[] – binData Double (IEEE 754 FP) Date (ms since epoch UTC) Null Boolean JavaScript String Regex ObjectId (ts(4)+ host(3) + pid(2)+ incr(3) ) 12-byte BSON Package
  • 14. Morphia: MongoDB Mapper Maps POJO Type-safe Access Patterns: DAO/Datastore/RollYourOwn Data Types Low performance overhead JPA like Many concepts came from Objectify (GAE)
  • 15. Annotations @Entity(“collectionName”) @Id @Transient (not transient) @Indexed(…) @Property(“fieldAlias”) @AlsoLoad({aliases}) @Reference @Serialized [@Embedded]
  • 16. Lifecycle Events @PrePersist @PreSave @PostPersist @PreLoad @PostLoad EntityListeners EntityInterceptor
  • 17. Datastore Basics get(class, id) find(class, […]) save(entity, […]) delete(query) getCount(query) update/First(query, upOps) findAndModify/Delete(query, upOps)
  • 18. Basic POJO @Entity class Person { @Id ObjectId name; SexEnum sex; @Indexed Integer height; }
  • 19. Queries Datastoreds = … 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();
  • 20. Save whole object graphs (get/save) Update parts (embedded objects) Un/set fields Push/pop arrays (lists) Increment numeric fields Any combination of the above Get/Save or Update
  • 21. Update Operations set(field, val) unset(field) inc(field, [val]) dec(field) add(field, val) addAdd(field, vals) removeFirst/Last(field) removeAll(field, vals)
  • 22. Update existing props Update w/new props Examples
  • 23. Update Datastoreds = … 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?
  • 24. Morphia Relationships Annotations [@Embedded] Load/Save with Entity Update @Reference Stored as DBRef(s) Loaded with Entity Not automatically saved Key<T> Stored as DBRef(s) Just a link, but resolvable by Datastore/Query