$data.fieldname to reference parent record fields.
joinOne (One-to-One)
Returns a single object or null. Use when you expect at most one related record.joinMany (One-to-Many)
Returns an array of related records. Use when you expect multiple related records.Multiple JOINs
Combine multiple joins in a single query:Nested JOINs
Chain JOINs before calling.build() to create nested relationships:
Self-Referential JOINs
Join a collection to itself:JoinBuilder Operators
Available operators ononField():
Complete Example: Social Feed
Performance Tips
- Index foreign keys - Ensure fields used in JOIN conditions are indexed
- Select only needed fields - Use
selectFields()instead ofselectAll()when possible - Limit nested data - For one-to-many JOINs, consider if you need all related records
- Use materialized views - For complex queries executed frequently, create a materialized view
Next Steps
Materialized Views
Pre-computed views for instant queries
CRUD Operations
Document operations with JOINs