SlideShare une entreprise Scribd logo
Rails + MongoDB = <3
Sérgio Santos
@sdsantos
Improve Coimbra
Introduction / Disclamer
Bundlr MongoDB stats
MongoDB from the start
~ 3½ years of development
~ 6 GB of data
~ 6 million documents
Cloud hosted on MongoHQ
MongoDB 101
Documents
Collections
References
Embeds
Rails MongoDB ORMs
Mongoid vs MongoMapper
Mongoid
Models
class Person
include Mongoid::Document
end
person = Person.new
person[:name] = 'Sérgio'
person[:age] = 26
person.save
Models
class Person
include Mongoid::Document
field :name, type: String
field :age, type: Integer
end
person = Person.new
person.name = 'Sérgio'
person.age = 26
person.save
Persistence
person = Person.create(name: 'Sérgio', age: 26)
person.update_attributes(name: 'Sérgio Santos')
person.touch
person.delete
person.destroy
person.rename(:name, :first_name)
Querying
person = Person.find("4baa56f1230048567300485c")
people = Person.where(age: 18)
people = Person.where(name: 'Sérgio').not(age: 26)
Person.count
Person.all.avg(:age)
-- INSERT MAP/REDUCE CLEVER EXAMPLE HERE --
References
class Band
include Mongoid::Document
has_many :members
end
class Member
include Mongoid::Document
field :name, type: String
belongs_to :band
end
References
# The parent band document.
{
"_id" : ObjectId("4d3ed089fb60ab534684b7e9")
}
# The child member document.
{
"_id" : ObjectId("4d3ed089fb60ab534684b7f1"),
"name" : "Matt Berninger"
"band_id" : ObjectId("4d3ed089fb60ab534684b7e9")
}
Embeds
class Band
include Mongoid::Document
embeds_many :albums
end
class Album
include Mongoid::Document
field :name, type: String
embedded_in :band
end
Embeds
{
"_id" : ObjectId("4d3ed089fb60ab534684b7e9"),
"albums" : [
{
"_id" : ObjectId("4d3ed089fb60ab534684b7e0"),
"name" : "Boxer",
}
]
}
Extras
identity map & cache
paranoia
versioning
timestamps
geo
full text search
Cloud Hosting
Wrapping up…
Rails + MongoDB = <3
Sérgio Santos
@sdsantos
me@sergiosantos.info
We’re hiring!
nourishcare.co.uk/careers/

Contenu connexe

En vedette

En vedette (11)

Happy Anniversary
Happy  AnniversaryHappy  Anniversary
Happy Anniversary
 
Human Due Diligence Methodology
Human Due Diligence MethodologyHuman Due Diligence Methodology
Human Due Diligence Methodology
 
Happy anniversary
Happy anniversaryHappy anniversary
Happy anniversary
 
Launching tech products
Launching tech productsLaunching tech products
Launching tech products
 
Due Diligence Methodology by Human Value International
Due Diligence Methodology by Human Value InternationalDue Diligence Methodology by Human Value International
Due Diligence Methodology by Human Value International
 
Online Searching Reality Check
Online Searching Reality CheckOnline Searching Reality Check
Online Searching Reality Check
 
Staff mentorship programe as a means of achieving world class university UJ
Staff mentorship programe as a means of achieving world class university UJStaff mentorship programe as a means of achieving world class university UJ
Staff mentorship programe as a means of achieving world class university UJ
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
SAP S/4HANA - What it really is and what not
SAP S/4HANA - What it really is and what notSAP S/4HANA - What it really is and what not
SAP S/4HANA - What it really is and what not
 
Ontologias
OntologiasOntologias
Ontologias
 
Workshop Django
Workshop DjangoWorkshop Django
Workshop Django
 

Dernier

Dernier (20)

Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 

Rails + mongo db