Skip to content

Latest commit

 

History

History
175 lines (129 loc) · 6.94 KB

File metadata and controls

175 lines (129 loc) · 6.94 KB
//////////////////////////////////////////////////////////////////////////////////////////////
// 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                                          //
//////////////////////////////////////////////////////////////////////////////////////////////

Index / Models / Task

🗃️ Task Model

A unit of work within a project. Tasks support self-referential parent/child hierarchy for sub-tasks.

Category: Work · Since: 1.0 · Defined in: showcase.zmodel


Declaration · showcase.zmodel
model Task with Timestamps {
    id          String      @id @default(cuid())
    title       String      @length(1, 200) @trim @meta('doc:example', 'Fix login redirect bug')
    body        String?
    slug        String?     @regex('^[a-z0-9-]+$')
    status      TaskStatus  @default(TODO)
    priority    Priority    @default(MEDIUM)
    dueDate     DateTime?
    estimatedHours Float?   @gt(0) @lte(1000)
    commentCount Int        @computed
    project     Project     @relation(fields: [projectId], references: [id])
    projectId   String
    assignee    User?       @relation(fields: [assigneeId], references: [id])
    assigneeId  String?
    parent      Task?       @relation("SubTasks", fields: [parentId], references: [id])
    parentId    String?
    children    Task[]      @relation("SubTasks")
    comments    Comment[]
    tags        Tag[]
    activities  Activity[]

    @@allow('read', true)
    @@allow('create,update', true)
    @@deny('delete', status == 'DONE')
    @@validate(estimatedHours == null || estimatedHours > 0, "Estimated hours must be positive when set")
    @@index([projectId])
    @@index([assigneeId])
    @@meta('doc:category', 'Work')
    @@meta('doc:since', '1.0')
}

On this page: Mixins · Fields · Relationships · Access Policies · Indexes · Validation Rules · Used in Procedures

🧩 Mixins

Reusable field groups mixed into this model.

📋 Fields

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
title String Yes @length(1, 200), @trim Example: Fix login redirect bug Short summary of the task.
body String? No Rich-text body with full details.
slug String? No @regex('^[a-z0-9-]+$') Unique slug for URL-friendly references.
status TaskStatus Yes TODO
priority Priority Yes MEDIUM
dueDate DateTime? No
estimatedHours Float? No @gt(0), @lte(1000) Estimated effort in hours.
commentCount Int computed Yes Number of comments on this task.
project Project Yes @relation(fields: [projectId], references: [id])
projectId String Yes
assignee User? No @relation(fields: [assigneeId], references: [id])
assigneeId String? No
parent Task? No @relation("SubTasks", fields: [parentId], references: [id]) Parent task — allows nesting sub-tasks.
parentId String? No
children Task[] No @relation("SubTasks")
comments Comment[] No
tags Tag[] No
activities Activity[] No

🔗 Relationships

Foreign key relationships to other models in the schema.

Field Related Model Type
activities Activity One→Many
assignee User Many→One?
children Task One→Many
comments Comment One→Many
parent Task Many→One?
project Project Many→One
tags Tag One→Many

diagram

🔐 Access Policies

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
create,update true Allow
delete status == 'DONE' Deny

📇 Indexes

Database indexes defined on this model for query performance.

Fields Type
[projectId] Index
[assigneeId] Index

✅ Validation Rules

Field-level and model-level validation constraints enforced at the ORM layer.

Field Rule
title @length
title @trim
slug @regex
estimatedHours @gt
estimatedHours @lte
Model `estimatedHours == null

⚡ Used in Procedures

Procedures that reference this entity as a parameter or return type.


📚 References


Previous: Tag · Next: Team