Entity
    Preparing search index...

    Class ReadonlyPostgresEntity<TFields, TIDField, TViewerContext, TSelectedFields>Abstract

    Abstract base class for readonly entities backed by Postgres. Provides knexLoader and knexLoaderWithAuthorizationResults as inherited static methods.

    Entities that should not be mutated (e.g., representing SQL views or immutable tables) can extend this class instead of ReadonlyEntity to get knex loader ergonomics.

    Type Parameters

    • TFields extends Record<string, any>
    • TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>
    • TViewerContext extends ViewerContext
    • TSelectedFields extends keyof TFields = keyof TFields

    Hierarchy

    Index

    Methods

    • Returns Readonly<TFields>

      all underlying fields from this entity's database data

    • Returns Readonly<Pick<TFields, TSelectedFields>>

      all underlying fields from this entity's data

    • Get a underlying field from this entity's data

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • fieldName: K

        the field to get

      Returns Pick<TFields, TSelectedFields>[K]

      the value of the field or undefined if not loaded with that field

    • Returns TFields[TIDField]

      the ID of this entity

    • Returns string

    • Returns TViewerContext

      the ViewerContext authorized to read this entity

    • Returns string