SlideShare uma empresa Scribd logo
1 de 24
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/

Mais conteúdo relacionado

Destaque

Destaque (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
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Rails + mongo db