ORM
  • Introduction
  • Basics of Usage
    • Connecting to the Database
    • Creating a Model
    • Simple Queries
  • Configuration
  • Core Features
    • Models
    • CRUD Operations (Create, Read, Update, Delete): examples
    • Relationships
    • Transactions
  • Advanced Usage
    • Data Definition Language
    • Indexes
    • Triggers
    • Caching
  • Examples and templates
  • Security
    • Query parameterization and protection against SQL injections
    • Logging
    • Monitoring
    • Sanitization
  • ORM-CLI
    • Installing
    • Commands and usage
  • System architecture and implementation
    • Support of various databases
      • Implementation using a pattern strategy
      • Implementation using generics
      • Implementation using metaprogramming
    • Decorators
    • Migrations
      • Assignment of id in Tables and Columns
      • Assigning IDs to indexes and triggers
      • Working with migrations in ORM-CLI
        • Implementation of a pattern command for migration
    • QueryBuilder
    • Caching
    • File structure
  • API
    • Decorators
      • Column
      • ComputedColumn
      • Index
      • ForeignKey
      • PrimaryGeneratedColumn
      • Relations
      • Table
      • Trigger
      • Types decorators
        • Integer
        • Numeric
        • Float
        • Boolean
        • String
    • DDL
    • QueryBuilder
    • Additional API
Powered by GitBook
On this page
  1. API
  2. Decorators

Column

Column Decorator

The Column decorator is used to describe columns in the database within your ORM system. It takes one parameter — an object of type ColumnDecoratorInterface, which contains options for configuring the column.

Parameters of ColumnDecoratorInterface

  • name:

    • Type: string

    • Description: Specifies the name of the column in the database. If not provided, the property name in the class is used.

  • options:

    • Type: ColumnOptionsDecoratorInterface

    • Description: An object containing additional options for configuring the column.

Parameters of ColumnOptionsDecoratorInterface

  • dataType:

    • Type: PostgresqlDataTypes | MysqlDataTypes

    • Description: Specifies the data type of the column depending on the database type (PostgreSQL or MySQL).

  • nullable:

    • Type: boolean

    • Description: Defines whether the column can contain NULL values. Defaults to false.

  • length:

    • Type: number

    • Description: Specifies the length of the data in the column. Applies to data types such as VARCHAR.

  • defaultValue:

    • Type: string | number | boolean

    • Description: The default value for the column.

  • unique:

    • Type: boolean

    • Description: Indicates whether the values in the column should be unique.

PostgreSQL-Specific:

  • check:

    • Type: string

    • Description: Condition for a CHECK constraint. Specified only for PostgreSQL.

  • nameOfCheckConstraint:

    • Type: string

    • Description: Name of the CHECK constraint. Applies only to PostgreSQL.

  • nullsNotDistinct:

    • Type: boolean

    • Description: Indicates whether NULL values should be treated as distinct. Used only in PostgreSQL.

  • precision:

    • Type: number

    • Description: Precision for numeric data. Applies only to PostgreSQL.

  • scale:

    • Type: number

    • Description: Number of digits after the decimal point. Applies only to PostgreSQL.

MySQL-Specific:

  • totalNumberOfDigits:

    • Type: number

    • Description: Total number of digits for numeric data. Applies only to MySQL.

  • numberOfDigitsAfterPoint:

    • Type: number

    • Description: Number of digits after the decimal point for numeric data. Applies only to MySQL.

  • displayWidth:

    • Type: number

    • Description: Display width for numeric data. Applies only to MySQL.

  • isUnsigned:

    • Type: boolean

    • Description: Indicates whether the numeric data is unsigned. Applies only to MySQL.

  • isZerofill:

    • Type: boolean

    • Description: Determines whether zeros should be added before the number to fill the width. Applies only to MySQL.

  • isAutoIncrement:

    • Type: boolean

    • Description: Indicates whether the column should automatically increment its value for each new record. Applies only to MySQL.

PreviousDecoratorsNextComputedColumn

Last updated 9 months ago