prorm API Reference
    Preparing search index...

    Function AbstractModel

    • Mark a class as an abstract base model.

      An abstract model gets no table of its own. Its columns, and any @PrimaryKey / @Default / validation applied to them, are inherited by the concrete models that extend it, so shared fields are declared once:

      // This is the base model, which defines the common fields between all comments.
      @AbstractModel()
      class BaseComment {
      @Column(DataTypes.INTEGER())
      @PrimaryKey()
      @AutoIncrement()
      declare id: number;

      @Column(DataTypes.TEXT())
      declare body: string;
      }

      @Table({ tableName: 'post_comments' })
      class PostComment extends BaseComment {
      @Column(DataTypes.INTEGER())
      declare postId: number;
      }

      PostComment is created with id, body and postId. Passing the abstract class itself to addModel() is an error - there is no table to address.

      Parameters

      • options: TableOptions = {}

      Returns ClassDecorator