Function Entity

  • A class decorator for marking a class as an entity within the context of the ORM system. This decorator is essential for registering the class as a distinct entity in the ORM's metadata system, enabling the ORM to recognize and manage instances of this class as part of its data model. By designating classes as entities, it facilitates their integration into the ORM framework, allowing for operations such as querying, persisting, and managing relationships between entities.

    IMPORTANT - All entity classes should extend a table class decorated by Table

    Type Parameters

    • T extends default

      The class being decorated, which extends from the base DynaRecord entity class. This ensures that only classes that are part of the ORM system can be decorated as entities.

    Parameters

    • target: (new () => T)

      The constructor function of the class being decorated. This function is used to instantiate objects of the class.

        • new (): T
        • Returns T

    • context: ClassDecoratorContext<(new (...args) => any)>

      The context in which the decorator is applied, provided by the TypeScript runtime. This includes metadata about the class, such as its kind and other relevant information. The decorator uses this context to perform its registration logic.

    Returns void

    The decorator does not return a value. Instead, it performs side effects by registering the class with the ORM's metadata system.

    Usage example:

    @Entity
    class User extends MyTable {
    // User entity implementation
    }

    In this example, the User class is marked as an entity using the @Entity decorator. This designation registers the User class within the ORM's metadata system, making it a recognized entity for the ORM to manage. The registration process involves associating the class with its corresponding table name and any additional metadata required by the ORM to handle instances of this class effectively.

Generated using TypeDoc