AutoBE
    Preparing search index...

    Interface representing a single Prisma model (database table).

    Based on the uploaded schemas, models follow specific patterns:

    • Main business entities (e.g., shopping_sales, shopping_customers)
    • Snapshot/versioning entities for audit trails (e.g., shopping_sale_snapshots)
    • Junction tables for M:N relationships (e.g., shopping_cart_commodity_stocks)
    • Materialized views for performance (prefixed with mv_)
    interface IModel {
        description: string;
        foreignFields: IForeignField[];
        ginIndexes: IGinIndex[];
        material: boolean;
        name: string & SnakePattern;
        plainFields: IPlainField[];
        plainIndexes: IPlainIndex[];
        primaryField: IPrimaryField;
        stance: "primary" | "subsidiary" | "snapshot";
        uniqueIndexes: IUniqueIndex[];
    }
    Index

    Properties

    description: string

    Detailed description explaining the business purpose and usage of the model.

    Should include:

    • Business context and purpose
    • Key relationships with other models
    • Important behavioral notes or constraints
    • References to related entities using "{@\link ModelName}" syntax

    IMPORTANT: Description must be written in English. Example: "Customer information, but not a person but a connection basis..."

    foreignFields: IForeignField[]

    Array of foreign key fields that reference other models.

    These establish relationships between models and include Prisma relation directives. Can be nullable (optional relationships) or required (mandatory relationships). May have unique constraints for 1:1 relationships.

    ginIndexes: IGinIndex[]

    Array of GIN (Generalized Inverted Index) indexes for full-text search.

    Used specifically for PostgreSQL text search capabilities using trigram operations. Applied to text fields that need fuzzy matching or partial text search. Examples: searching names, nicknames, titles, content bodies.

    material: boolean

    Indicates whether this model represents a materialized view for performance optimization.

    Materialized views are read-only computed tables that cache complex query results. They're marked as "@\hidden" in documentation and prefixed with "mv_" in naming. Examples: mv_shopping_sale_last_snapshots, mv_shopping_cart_commodity_prices

    name: string & SnakePattern

    Name of the Prisma model (database table name).

    MUST use snake_case naming convention. Examples: "shopping_customers", "shopping_sale_snapshots", "bbs_articles" Materialized views use "mv_" prefix: "mv_shopping_sale_last_snapshots"

    plainFields: IPlainField[]

    Array of regular data fields that don't reference other models.

    Include business data like names, descriptions, timestamps, flags, amounts, etc. Common patterns: created_at, updated_at, deleted_at for soft deletion and auditing.

    plainIndexes: IPlainIndex[]

    Array of regular indexes for query performance optimization.

    Speed up common query patterns like filtering by foreign keys, date ranges, or frequently searched fields. Examples: indexes on created_at, foreign key fields, search fields.

    primaryField: IPrimaryField

    The primary key field of the model.

    In all uploaded schemas, primary keys are always UUID type with "@\id" directive. Usually named "id" and marked with "@\db.Uuid" for PostgreSQL mapping.

    stance: "primary" | "subsidiary" | "snapshot"

    Specifies the architectural stance of this model within the database system.

    This property defines how the table positions itself in relation to other tables and what role it plays in the overall data architecture, particularly for API endpoint generation and business logic organization.

    Tables that represent core business concepts and serve as the primary subjects of user operations. These tables typically warrant independent CRUD API endpoints since users directly interact with these entities.

    Key principle: If users need to independently create, search, filter, or manage entities regardless of their parent context, the table should be primary stance.

    API Requirements:

    • Independent creation endpoints (POST /articles, POST /comments)
    • Search and filtering capabilities across all instances
    • Direct update and delete operations
    • List/pagination endpoints for browsing

    Why bbs_article_comments is primary, not subsidiary:

    Although comments belong to articles, they require independent management:

    • Search across articles: "Find all comments by user X across all articles"
    • Moderation workflows: "List all pending comments for review"
    • User activity: "Show all comments made by this user"
    • Independent operations: Users edit/delete their comments directly
    • Notification systems: "Alert when any comment is posted"

    If comments were subsidiary, these operations would be impossible or require inefficient nested queries through parent articles.

    Characteristics:

    • Represents tangible business concepts that users manage
    • Serves as reference points for other tables
    • Requires comprehensive API operations (CREATE, READ, UPDATE, DELETE)
    • Forms the backbone of the application's business logic

    Examples:

    • bbs_articles - Forum posts that users create, edit, and manage
    • bbs_article_comments - User comments that require independent management

    Tables that exist to support primary entities but are not independently managed by users. These tables are typically managed through their parent entities and may not need standalone API endpoints.

    Characteristics:

    • Depends on primary or snapshot entities for context
    • Often managed indirectly through parent entity operations
    • May have limited or no independent API operations
    • Provides supporting data or relationships

    Examples:

    • bbs_article_snapshot_files - Files attached to article snapshots
    • bbs_article_snapshot_tags - Tags associated with article snapshots
    • bbs_article_comment_snapshot_files - Files attached to comment snapshots

    Tables that capture point-in-time states of primary entities for audit trails, version control, or historical tracking. These tables record changes but are rarely modified directly by users.

    Characteristics:

    • Captures historical states of primary entities
    • Typically append-only (rarely updated or deleted)
    • Referenced for audit trails and change tracking
    • Usually read-only from user perspective

    Examples:

    • bbs_article_snapshots - Historical states of articles
    • bbs_article_comment_snapshots - Comment modification history

    The stance property guides automatic API endpoint generation:

    • "primary" → Generate full CRUD endpoints based on business requirements
    • "subsidiary" → Evaluate carefully; often managed through parent entities
    • "snapshot" → Typically read-only endpoints for historical data access
      // Primary business entity - needs full CRUD API
    {
    name: "bbs_articles",
    stance: "primary",
    description: "Forum articles that users create and manage independently"
    }

    // Another primary entity - despite being "child" of articles
    {
    name: "bbs_article_comments",
    stance: "primary",
    description: "User comments requiring independent search and management"
    }

    // Subsidiary entity - managed through snapshot operations
    {
    name: "bbs_article_snapshot_files",
    stance: "subsidiary",
    description: "Files attached to article snapshots, managed via snapshot APIs"
    }

    // Snapshot entity - read-only historical data
    {
    name: "bbs_article_snapshots",
    stance: "snapshot",
    description: "Historical states of articles for audit and versioning"
    }
    uniqueIndexes: IUniqueIndex[]

    Array of unique indexes for enforcing data integrity constraints.

    Ensure uniqueness across single or multiple columns. Examples: unique email addresses, unique codes within a channel, unique combinations like (channel_id, nickname).