Skip to main content
ChameleonDB supports advanced query operations for sorting, pagination, field projection, and debugging.

Order By

Sort results by one or more fields:

Multiple Order Clauses

Chain multiple OrderBy() calls for complex sorting:
The order of OrderBy() calls matters. The first call is the primary sort, the second is the secondary sort, etc.

Limit and Offset

Paginate results using Limit() and Offset():
Best practice: Always use OrderBy() with Limit()/Offset() to ensure deterministic pagination.Without ordering, the database may return results in arbitrary order, causing inconsistent pagination.

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
Use .Debug() during development to understand query performance and verify SQL generation.

Combining Everything

A realistic query combining multiple features:

What This Query Does:

  1. Finds users who are 18+ years old
  2. Who have at least one order with total > $50
  3. Loads all their orders (not just the ones > $50)
  4. Loads all items for those orders
  5. Sorts by most recent users first
  6. Returns only the first 10 results

Complex Filtering Example

Validation Rules

ChameleonDB validates queries before execution:

Query Performance Tips

Only select the fields you need with .Select() to reduce memory and network transfer.
Only include relations you actually need. Each Include() triggers an additional query.
Without ordering, pagination results may be inconsistent.
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