Skip to content

Latest commit

 

History

History
133 lines (91 loc) · 4.39 KB

File metadata and controls

133 lines (91 loc) · 4.39 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 / Organization

🗃️ Organization Model

An organization is the top-level tenant in the system. All users, teams, and projects belong to exactly one organization.

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


Declaration · showcase.zmodel
model Organization with Timestamps {
    id       String    @id @default(cuid())
    name     String    @length(2, 100)
    slug     String    @unique @length(3, 40) @meta('doc:example', 'acme-corp')
    email    String?   @email
    memberCount Int       @computed
    users    User[]
    teams    Team[]
    projects Project[]

    @@allow('read', true)
    @@allow('update,delete', users?[role == 'OWNER'])
    @@index([slug])
    @@meta('doc:category', 'Core')
    @@meta('doc:since', '1.0')
}

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

🧩 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
name String Yes @length(2, 100) The public display name of the organization.
slug String Yes @unique, @length(3, 40) Example: acme-corp URL-safe identifier used in routing.
email String? No @email Primary contact email for the organization.
memberCount Int computed Yes Total number of users across all teams.
users User[] No
teams Team[] No
projects Project[] No

🔗 Relationships

Foreign key relationships to other models in the schema.

Field Related Model Type
projects Project One→Many
teams Team One→Many
users User 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
update,delete users?[role == 'OWNER'] Allow

📇 Indexes

Database indexes defined on this model for query performance.

Fields Type
[slug] Index

✅ Validation Rules

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

Field Rule
name @length
slug @length
email @email

📚 References


Previous: Comment · Next: Project