Order By
Sort results by one or more fields:Multiple Order Clauses
Chain multipleOrderBy() calls for complex sorting:
Limit and Offset
Paginate results usingLimit() and Offset():
Pagination Example
Implementing cursor-based pagination:Select (Field Projection)
Select only the fields you need:Performance: Field projection reduces memory usage and network transfer. Only select the fields you actually need.
Debug Mode
See generated SQL and query performance:Debug Output Includes:
- Generated SQL - The exact SQL sent to the database
- Execution time - How long the query took
- Row count - Number of rows returned
Combining Everything
A realistic query combining multiple features:What This Query Does:
- Finds users who are 18+ years old
- Who have at least one order with total > $50
- Loads all their orders (not just the ones > $50)
- Loads all items for those orders
- Sorts by most recent users first
- Returns only the first 10 results
Complex Filtering Example
Validation Rules
ChameleonDB validates queries before execution:Query Performance Tips
Use field projection
Use field projection
Only select the fields you need with
.Select() to reduce memory and network transfer.Use eager loading wisely
Use eager loading wisely
Only include relations you actually need. Each
Include() triggers an additional query.Always order when paginating
Always order when paginating
Without ordering, pagination results may be inconsistent.
Use Debug mode to optimize
Use Debug mode to optimize
See the generated SQL to identify performance issues.
Limitations (v0.1)
These features are not supported in the current version:- Aggregations (
count,sum,avg) - Group by
- Subqueries
- Transactions
- OR logic (all filters are AND)
These features are planned for future versions. Track progress on GitHub.
Complete Example
What’s Next?
Filtering
Review filter operators (eq, gt, like, in)
Relations
Master eager loading with Include()
Mutations
Learn about Insert, Update, and Delete operations