Concepts
The Problem ORMs Solve
# Raw SQL approach
result = db.exec("SELECT id, name, email FROM users WHERE id = ?", [1])
row = result.first
user_id = row[0].as(Int64)
user_name = row[1].as(String)
user_email = row[2].as(String)# ORM approach
user = User.find(1)
puts user.name
puts user.emailKey Concepts
Models
Queries
ORM Method
SQL Equivalent
Relationships
Benefits of Using an ORM
1. Type Safety
2. Security
3. Productivity
4. Database Portability
5. Maintainability
When NOT to Use an ORM
ORM Patterns
Active Record
Other Patterns
Summary
Last updated
Was this helpful?