//////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE //
// This file is automatically generated by ZenStack CLI and should not be manually updated. //
// Source: schema.zmodel · Generated: 2026-02-23 //
//////////////////////////////////////////////////////////////////////////////////////////////
Index / Models / NotificationPreference
Per-user notification delivery preferences.
Each record controls whether a specific notification type is delivered via a given channel. If no preference exists for a type/channel combination, the system default applies:
- IN_APP: always on (cannot be disabled)
- EMAIL: on for CRITICAL, off for INFO/WARNING
- PUSH: off by default
Preferences are workspace-independent — they apply globally to the user's account.
Category: Notifications · Since: 2.0 · Defined in: notifications.zmodel
Declaration · notifications.zmodel
model NotificationPreference with Timestamps {
id String @id @default(cuid())
type String @length(1, 80) @meta('doc:example', 'comment.created')
channel NotificationChannel
enabled Boolean @default(true)
user User @relation(fields: [userId], references: [id])
userId String
@@unique([userId, type, channel])
@@meta('doc:category', 'Notifications')
@@meta('doc:since', '2.0')
}On this page: Mixins · Fields · Relationships · Indexes · Validation Rules
Reusable field groups mixed into this model.
All fields defined on this entity, including inherited fields from mixins and parent models.
| Field | Type | Required | Default | Attributes | Source | Description |
|---|---|---|---|---|---|---|
createdAt |
DateTime |
Yes | now() |
— | Timestamps | When the record was first created. Immutable after insert. |
updatedAt |
DateTime |
Yes | — | @updatedAt |
Timestamps | When the record was last modified. Updated automatically. |
id |
String |
Yes | cuid() |
@id |
— | — |
type |
String |
Yes | — | @length(1, 80) |
— | Example: comment.created The notification type this preference applies to. |
Use * as a wildcard to set defaults for all types. |
||||||
channel |
NotificationChannel | Yes | — | — | — | The delivery channel this preference controls. |
enabled |
Boolean |
Yes | true |
— | — | Whether delivery via this channel is enabled. |
user |
User | Yes | — | @relation(fields: [userId], references: [id]) |
— | — |
userId |
String |
Yes | — | — | — | — |
Foreign key relationships to other models in the schema.
| Field | Related Model | Type |
|---|---|---|
user |
User | Many→One |
Database indexes defined on this model for query performance.
| Fields | Type |
|---|---|
[userId, type, channel] |
Unique |
Field-level and model-level validation constraints enforced at the ORM layer.
| Field | Rule |
|---|---|
type |
@length |
Previous: Notification · Next: Subscription