Entity
    Preparing search index...

    Class EnforcingKnexEntityLoader<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>

    Enforcing knex entity loader for non-data-loader-based load methods. All loads through this loader will throw if the load is not successful.

    Type Parameters

    Index

    Constructors

    Properties

    metricsAdapter: IEntityMetricsAdapter

    Methods

    • Get cursor for a given entity that matches what loadPageAsync would produce. Useful for constructing pagination cursors for entities returned from other loader methods that can then be passed to loadPageAsync for pagination. Most commonly used for testing pagination behavior.

      Parameters

      • entity: TEntity

        The entity to get the pagination cursor for.

      Returns string

      The pagination cursor for the given entity.

    • Load entities with a raw SQL WHERE clause.

      Parameters

      • rawWhereClause: string

        SQL WHERE clause. Interpolated values should be specified as ?-placeholders or :key_name

      • bindings: object | any[]

        values to bind to the placeholders in the WHERE clause

      • querySelectionModifiers: EntityLoaderQuerySelectionModifiers<TFields, TSelectedFields> = {}

        limit, offset, and orderBy for the query.

      Returns Promise<readonly TEntity[]>

      entities matching the WHERE clause

      Load entities with SQL function

      const entitiesWithJsonKey = await ExampleEntity.loader(vc)
      .loadManyByRawWhereClauseAsync(
      "json_column->>'key_name' = ?",
      ['value'],
      );

      Load entities with tuple matching

      const entities = await ExampleEntity.loader(vc)
      .loadManyByRawWhereClauseAsync(
      '(column_1, column_2) IN ((?, ?), (?, ?))',
      [value1, value2, value3, value4],
      );

      EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities

      Error when rawWhereClause or bindings are invalid

      Use loadManyBySQL instead for safer value bindings and more flexible query building.