//////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE //
// This file is automatically generated by ZenStack CLI and should not be manually updated. //
// Source: showcase.zmodel · Generated: 2026-02-23 //
//////////////////////////////////////////////////////////////////////////////////////////////
A registered user in the platform. Users belong to an organization and may be members of multiple teams.
Category: Identity · Since: 1.0 · Defined in: showcase.zmodel
Declaration · showcase.zmodel
model User with Timestamps {
id String @id @default(cuid())
email String @unique @email @meta('doc:example', 'jane@acme.com')
name String @length(1, 120)
avatarUrl String? @url
role Role @default(MEMBER)
taskCount Int @computed
organization Organization @relation(fields: [organizationId], references: [id])
organizationId String
memberships TeamMember[]
assignedTasks Task[]
comments Comment[]
activities Activity[]
@@allow('read', true)
@@allow('update', this == auth())
@@deny('delete', role == 'OWNER')
@@index([email])
@@unique([email, organizationId])
@@meta('doc:category', 'Identity')
@@meta('doc:since', '1.0')
}On this page: Mixins · Fields · Relationships · Access Policies · Indexes · Validation Rules · Used in Procedures
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 | — |
updatedAt |
DateTime |
Yes | — | @updatedAt |
Timestamps | — |
id |
String |
Yes | cuid() |
@id |
— | — |
email |
String |
Yes | — | @unique, @email |
— | Example: jane@acme.com Email address used for login. |
name |
String |
Yes | — | @length(1, 120) |
— | Full name displayed in the UI. |
avatarUrl |
String? |
No | — | @url |
— | URL to the user's avatar image. |
role |
Role | Yes | MEMBER |
— | — | — |
taskCount |
Int computed |
Yes | — | — | — | — |
organization |
Organization | Yes | — | @relation(fields: [organizationId], references: [id]) |
— | — |
organizationId |
String |
Yes | — | — | — | — |
memberships |
TeamMember[] | No | — | — | — | — |
assignedTasks |
Task[] | No | — | — | — | — |
comments |
Comment[] | No | — | — | — | — |
activities |
Activity[] | No | — | — | — | — |
Foreign key relationships to other models in the schema.
| Field | Related Model | Type |
|---|---|---|
activities |
Activity | One→Many |
assignedTasks |
Task | One→Many |
comments |
Comment | One→Many |
memberships |
TeamMember | One→Many |
organization |
Organization | Many→One |
ZenStack access control rules that determine who can read, create, update, or delete records.
Important
Operations are denied by default. @@allow rules grant access; @@deny rules override any allow.
| Operation | Rule | Effect |
|---|---|---|
| read | true |
Allow |
| update | this == auth() |
Allow |
| delete | role == 'OWNER' |
Deny |
Database indexes defined on this model for query performance.
| Fields | Type |
|---|---|
[email] |
Index |
[email, organizationId] |
Unique |
Field-level and model-level validation constraints enforced at the ORM layer.
| Field | Rule |
|---|---|
email |
@email |
name |
@length |
avatarUrl |
@url |
Procedures that reference this entity as a parameter or return type.
- getUser — query
- listOrgUsers — query
- signUp — mutation
Previous: TeamMember