Query Builder
Prism’sPrismQueryBuilder lets you construct SQL queries with a fluent Swift API. It’s not an ORM — it generates SQL strings and parameter arrays, giving you the safety of parameterized queries with the readability of a builder pattern.
Basic Queries
Select
Select All Columns
Select Specific Columns
Where Clauses
Filtering Results
.where() calls are joined with AND:
Combined Conditions
Ordering
Sort Results
Pagination
Limit and Offset
Write Operations
- Insert
- Update
- Delete
Insert a Row
Counting
Count Rows
Practical Example: Paginated API
Here’s how you’d build a paginated endpoint for a blog API:Paginated Posts API
When to Use Raw SQL
The query builder handles common cases well. For complex joins, subqueries, or database-specific features, drop down to raw SQL:Complex Raw Query
PrismDatabase, so you can mix them freely.