SlideShare a Scribd company logo
1 of 35
Download to read offline
Voyage by example 
tips and tricks on persisting object models
Esteban Lorenzano 
Pharo core developer 
INRIA - RMoD 
http://smallworks.eu
Why? 
• You already know about Voyage 
• You already attended to a tutorial last year 
• But there are some recurrent problems people find 
when trying to use it 
• And I’m still seeing a lot of people that could be 
using it and they chose other solutions
What is Voyage? (1) 
• Simple abstraction layer to map objects into a database 
- Very well suited for document databases, but in theory, 
the approach will work for other kind of repositories 
‣ There was (long time ago) a Voyage-GLORP backend 
‣ There was (even more time ago) a Voyage- 
ImageSegment backend 
- Voyage-Memory, Voyage-Mongo
What is Voyage? (2) 
• Did I said is simple? 
• it ensures object identity 
• it provides error handling 
• it implements a connection pool
Voyage principles 
• Behavioural complete (for common usage), but 
decoupled approach also possible. 
• Same design for different backends, but not a 
common abstraction 
- There is no such thing as a “voyage query 
language”, etc. 
- is a bit more work for users who want to switch, 
but a lot more happiness for the program itself
Voyage ultimate goal 
To be the GLORP for NoSQL databases
The problem to solve
Impedance mistmatch 
Class A Class B Class C 
Table A Table B Table C 
1..* 
*..* 
Ideal relational model
Impedance mistmatch 
aColection 
anObject otherObject 
firstObject 
secondObject 
thirdObject 
Real object model
Impedance mistmatch 
aColection 
anObject otherObject 
Real object model 
firstObject 
secondObject 
thirdObject
Impedance mistmatch 
aColection 
anObject otherObject 
Real object model 
firstObject 
secondObject 
thirdObject
So, what about those tips?
Think in objects
A simple model 
*..* 
Hero Power
Persist 
(Hero named: ‘Groot’) 
addPower: ((Power named: ‘Plant Control’) 
level: #epic; 
yourself); 
save.
Persist 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Groot’, 
powers: [ { #collection: ‘Power’, __id: OID(…) } ] 
} 
! 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Power’, 
name: ‘Plant Control’, 
level: #epic, 
heroes: [ #collection: ‘Hero’, __id: OID(…) ] 
}
Take control
A simple model 
(a bit more complete) 
*..* 
Hero Power 
1..* 
Equipment 
Container Pistol 
1..*
Persist 
(Hero named: ‘Star-lord’) 
addEquipment: (Container 
addItem: Pistol new; 
yourself); 
save.
Persist (1) 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Persist (2) 
{ 
_id: OID(1), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { #collection: ‘Equipment’, __id: OID(2) } ] 
} 
! 
{ 
_id: OID(2), 
#version: …, 
#instanceOf: ‘Container’, 
items: [ { #collection: ‘Equipment’, __id: OID(3) } ] 
} 
! 
{ 
_id: OID(3), 
#version: …, 
#instanceOf: ‘Pistol’, 
}
Integrity is a 
consequence
Allowing missing content 
• We do not have foreign keys 
- So we cannot do things like “ON DELETE 
CASCADE” 
- Even delete validations are difficult 
‣ Imagine “hero” has a “power”,and I remove the 
“power”. How can the hero notice it?
Persist 
mongoContainer 
<mongoContainer> 
! 
^ VOMongoContainer new 
collectionName: ‘powers’; 
enableMissingContent; 
yourself
Querying smart
Query (1) 
Hero 
selectMany: [ :each | … ] 
sortBy: { #name -> VOOrder ascending } asDictionary 
limit: 100 
offset: 100
Query (2) 
Hero 
selectMany: { 
‘name’ -> { 
‘$regexp’ -> ‘^G.*’. 
‘$options’ -> ‘i’ 
} asDictionary 
} asDictionary
Adapt schemes
The “scheme is not mine” 
problem 
• You can move meta-information to your program 
• Magritte-Voyage gives you a lot of power 
• You can extend/modify parts of the updating 
system too (like versioning)
Meta-information 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Meta-information 
{ 
_id: OID(…), 
#version: …, 
#instanceOf: ‘Hero’, 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
#instanceOf: ‘Container’, 
‘items’, [ 
{ #instanceOf: ‘Pistol’ } ] } ] 
}
Meta-information 
{ 
_id: OID(…), 
name: ‘Star-lord’, 
powers: [], 
equipment: [ { 
‘items’, [ {} ] } ] 
}
Voyage 2.0 
• Root detection (enhance save & update) 
• Cyclic detection 
- Add strategy to persist cycles even without roots (It has some 
consequences (in querying, etc.), so it will be optional) 
• integrity validations 
- #removeWithDependencies 
• Materialisation customisations 
- #readRaw 
• Add backend: Riak
Use it today! 
Gofer it 
smalltalkhubUser: ‘Pharo’ project: ’MetaRepoForPharo30’; 
configurationOf: ‘VoyageMongo’; 
loadStable. 
Thanks!! 
Esteban Lorenzano - 2014

More Related Content

What's hot

Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
Dave Cross
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
techvoltz
 

What's hot (19)

Redis and Ohm
Redis and OhmRedis and Ohm
Redis and Ohm
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Smalltalk on rubinius
Smalltalk on rubiniusSmalltalk on rubinius
Smalltalk on rubinius
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuery
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Multitenant applications: How and Why
Multitenant applications: How and WhyMultitenant applications: How and Why
Multitenant applications: How and Why
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in Redis
 
Sprockets
SprocketsSprockets
Sprockets
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
 
Essential YUI
Essential YUIEssential YUI
Essential YUI
 
Advanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDBAdvanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDB
 
Getting startedwith noir-clojureexchange-2011
Getting startedwith noir-clojureexchange-2011Getting startedwith noir-clojureexchange-2011
Getting startedwith noir-clojureexchange-2011
 
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013
 
Using Data That Isn't Yours
Using Data That Isn't YoursUsing Data That Isn't Yours
Using Data That Isn't Yours
 
Introduction to Ruby, Rails, and Ruby on Rails
Introduction to Ruby, Rails, and Ruby on RailsIntroduction to Ruby, Rails, and Ruby on Rails
Introduction to Ruby, Rails, and Ruby on Rails
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 

Similar to Voyage by example

【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
taobao.com
 

Similar to Voyage by example (20)

Voyage by example
Voyage by exampleVoyage by example
Voyage by example
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Dependency injectionpreso
Dependency injectionpresoDependency injectionpreso
Dependency injectionpreso
 
Week3
Week3Week3
Week3
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Design patterns
Design patternsDesign patterns
Design patterns
 
About Python
About PythonAbout Python
About Python
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践【前端Mvc】之豆瓣说实践
【前端Mvc】之豆瓣说实践
 
Learn JS concepts by implementing jQuery
Learn JS concepts by implementing jQueryLearn JS concepts by implementing jQuery
Learn JS concepts by implementing jQuery
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Recently uploaded (20)

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

Voyage by example

  • 1. Voyage by example tips and tricks on persisting object models
  • 2. Esteban Lorenzano Pharo core developer INRIA - RMoD http://smallworks.eu
  • 3. Why? • You already know about Voyage • You already attended to a tutorial last year • But there are some recurrent problems people find when trying to use it • And I’m still seeing a lot of people that could be using it and they chose other solutions
  • 4. What is Voyage? (1) • Simple abstraction layer to map objects into a database - Very well suited for document databases, but in theory, the approach will work for other kind of repositories ‣ There was (long time ago) a Voyage-GLORP backend ‣ There was (even more time ago) a Voyage- ImageSegment backend - Voyage-Memory, Voyage-Mongo
  • 5. What is Voyage? (2) • Did I said is simple? • it ensures object identity • it provides error handling • it implements a connection pool
  • 6. Voyage principles • Behavioural complete (for common usage), but decoupled approach also possible. • Same design for different backends, but not a common abstraction - There is no such thing as a “voyage query language”, etc. - is a bit more work for users who want to switch, but a lot more happiness for the program itself
  • 7. Voyage ultimate goal To be the GLORP for NoSQL databases
  • 9. Impedance mistmatch Class A Class B Class C Table A Table B Table C 1..* *..* Ideal relational model
  • 10. Impedance mistmatch aColection anObject otherObject firstObject secondObject thirdObject Real object model
  • 11. Impedance mistmatch aColection anObject otherObject Real object model firstObject secondObject thirdObject
  • 12. Impedance mistmatch aColection anObject otherObject Real object model firstObject secondObject thirdObject
  • 13. So, what about those tips?
  • 15. A simple model *..* Hero Power
  • 16. Persist (Hero named: ‘Groot’) addPower: ((Power named: ‘Plant Control’) level: #epic; yourself); save.
  • 17. Persist { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Groot’, powers: [ { #collection: ‘Power’, __id: OID(…) } ] } ! { _id: OID(…), #version: …, #instanceOf: ‘Power’, name: ‘Plant Control’, level: #epic, heroes: [ #collection: ‘Hero’, __id: OID(…) ] }
  • 19. A simple model (a bit more complete) *..* Hero Power 1..* Equipment Container Pistol 1..*
  • 20. Persist (Hero named: ‘Star-lord’) addEquipment: (Container addItem: Pistol new; yourself); save.
  • 21. Persist (1) { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 22. Persist (2) { _id: OID(1), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #collection: ‘Equipment’, __id: OID(2) } ] } ! { _id: OID(2), #version: …, #instanceOf: ‘Container’, items: [ { #collection: ‘Equipment’, __id: OID(3) } ] } ! { _id: OID(3), #version: …, #instanceOf: ‘Pistol’, }
  • 23. Integrity is a consequence
  • 24. Allowing missing content • We do not have foreign keys - So we cannot do things like “ON DELETE CASCADE” - Even delete validations are difficult ‣ Imagine “hero” has a “power”,and I remove the “power”. How can the hero notice it?
  • 25. Persist mongoContainer <mongoContainer> ! ^ VOMongoContainer new collectionName: ‘powers’; enableMissingContent; yourself
  • 27. Query (1) Hero selectMany: [ :each | … ] sortBy: { #name -> VOOrder ascending } asDictionary limit: 100 offset: 100
  • 28. Query (2) Hero selectMany: { ‘name’ -> { ‘$regexp’ -> ‘^G.*’. ‘$options’ -> ‘i’ } asDictionary } asDictionary
  • 30. The “scheme is not mine” problem • You can move meta-information to your program • Magritte-Voyage gives you a lot of power • You can extend/modify parts of the updating system too (like versioning)
  • 31. Meta-information { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 32. Meta-information { _id: OID(…), #version: …, #instanceOf: ‘Hero’, name: ‘Star-lord’, powers: [], equipment: [ { #instanceOf: ‘Container’, ‘items’, [ { #instanceOf: ‘Pistol’ } ] } ] }
  • 33. Meta-information { _id: OID(…), name: ‘Star-lord’, powers: [], equipment: [ { ‘items’, [ {} ] } ] }
  • 34. Voyage 2.0 • Root detection (enhance save & update) • Cyclic detection - Add strategy to persist cycles even without roots (It has some consequences (in querying, etc.), so it will be optional) • integrity validations - #removeWithDependencies • Materialisation customisations - #readRaw • Add backend: Riak
  • 35. Use it today! Gofer it smalltalkhubUser: ‘Pharo’ project: ’MetaRepoForPharo30’; configurationOf: ‘VoyageMongo’; loadStable. Thanks!! Esteban Lorenzano - 2014