Skip to main content

Models

PrismModel bridges the gap between your database rows and Swift structs. Define a model, and you get find, all, insert, and delete for free.

Defining a Model

User Model
The primaryKey defaults to "id". Override it if your table uses a different column name.

CRUD Operations

Find by ID

Find a User

Fetch All

Fetch All Users

Insert

Create a User

Delete

Delete a User

REST API with Models

Here’s a complete CRUD API using models:
Users API
Models are lightweight Swift structs — no magic, no reflection, no runtime overhead. The PrismRow initializer gives you full control over how database values map to your properties.

Custom Primary Keys

Custom Primary Key