Libraries
    Preparing search index...

    Interface VariantDbSet<TEntity, K>

    A DbSet-like handle scoped to a single polymorphic variant (one branch of a discriminated union entity). All reads are automatically pre-filtered by the discriminator; all writes apply the correct STI / CTI logic.

    Obtain via DbSet.ofVariant('key') — analogous to EF Core's Set<DerivedType>().

    interface VariantDbSet<TEntity extends Entity<any, any, any>, K extends string> {
        andWhere(
            column: ColumnRef<EntitySchema<TEntity>>,
            operator: string,
            value: any,
        ): this;
        andWhere(column: ColumnRef<EntitySchema<TEntity>>, value: any): this;
        andWhere(record: Record<string, any>): this;
        andWhere(callback: (builder: QueryBuilder) => void): this;
        andWhere(raw: Raw): this;
        apply(fn: (builder: QueryBuilder) => void): this;
        avg(column: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        bulkInsert(
            rows: InferType<
                ReturnType<EntitySchema<TEntity>["makeAllPropsOptional"]>,
            >[],
            opts?: {
                chunkSize?: number;
                conflictColumns?: ColumnRef<EntitySchema<TEntity>>[];
                onConflict?: "ignore" | "merge";
            },
        ): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[]>;
        bulkUpdate(
            updates: readonly {
                set: Partial<InferType<TLocalSchema>>;
                where: Partial<InferType<TLocalSchema>>;
            }[],
        ): Promise<number>;
        bulkUpsert(
            rows: InferType<
                ReturnType<EntitySchema<TEntity>["makeAllPropsOptional"]>,
            >[],
            opts: {
                chunkSize?: number;
                conflictColumns: ColumnRef<EntitySchema<TEntity>>[];
            },
        ): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[]>;
        count(column?: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        countDistinct(column?: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        delete(): Promise<void>;
        distinct(...columns: (Raw<any> | ColumnRef<EntitySchema<TEntity>>)[]): this;
        execute(): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[]>;
        find(
            pk: PrimaryKeyValueOf<EntitySchema<TEntity>>,
        ): Promise<VariantResult<TEntity, K> | undefined>;
        findMany(
            pks: readonly PrimaryKeyValueOf<EntitySchema<TEntity>>[],
        ): Promise<VariantResult<TEntity, K>[]>;
        findOrFail(
            pk: PrimaryKeyValueOf<EntitySchema<TEntity>>,
        ): Promise<VariantResult<TEntity, K>>;
        first(): Promise<
            ExtractBranch<EntityResultByVariant<TEntity>, K>
            | undefined,
        >;
        groupBy(...columns: (Raw<any> | ColumnRef<EntitySchema<TEntity>>)[]): this;
        groupByRaw(sql: string, ...bindings: any[]): this;
        hardDelete(): Promise<number>;
        having(
            column: Raw<any> | ColumnRef<EntitySchema<TEntity>>,
            operator: string,
            value: any,
        ): this;
        havingRaw(sql: string, ...bindings: any[]): this;
        include<R extends string>(
            sel: (t: RelKeyTree<TEntity>) => R,
            customize?: (q: SchemaQueryBuilder<any, any>) => void,
        ): VariantDbSet<TEntity, K>;
        insert(
            payload: VariantInsertPayload<TEntity, K>,
        ): Promise<VariantResult<TEntity, K>>;
        insertMany(
            data: InferType<
                ReturnType<EntitySchema<TEntity>["makeAllPropsOptional"]>,
            >[],
        ): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[]>;
        joinMany<
            TForeignSchema extends
                ObjectSchemaBuilder<any, any, any, any, any, any, any>,
            TFieldName extends string,
        >(
            spec: JoinManySpec<EntitySchema<TEntity>, TForeignSchema, TFieldName>,
        ): SchemaQueryBuilder<
            EntitySchema<TEntity>,
            WithJoinedMany<
                ExtractBranch<EntityResultByVariant<TEntity>, K>,
                TFieldName,
                TForeignSchema,
            >,
        >;
        joinOne<
            TForeignSchema extends
                ObjectSchemaBuilder<any, any, any, any, any, any, any>,
            TFieldName extends string,
            TRequired extends boolean = true,
        >(
            spec: JoinOneSpec<
                EntitySchema<TEntity>,
                TForeignSchema,
                TFieldName,
                TRequired,
            >,
        ): SchemaQueryBuilder<
            EntitySchema<TEntity>,
            WithJoinedOne<
                ExtractBranch<EntityResultByVariant<TEntity>, K>,
                TFieldName,
                TForeignSchema,
                TRequired,
            >,
        >;
        limit(n: number): this;
        max(column: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        min(column: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        offset(n: number): this;
        onConflict(
            ...conflictColumns: ColumnRef<EntitySchema<TEntity>>[],
        ): OnConflictBuilder<
            EntitySchema<TEntity>,
            ExtractBranch<EntityResultByVariant<TEntity>, K>,
        >;
        onlyDeleted(): this;
        orderBy(
            column: Raw<any> | ColumnRef<EntitySchema<TEntity>>,
            direction?: "asc" | "desc",
        ): this;
        orderByRaw(sql: string, ...bindings: any[]): this;
        orWhere(
            column: ColumnRef<EntitySchema<TEntity>>,
            operator: string,
            value: any,
        ): this;
        orWhere(column: ColumnRef<EntitySchema<TEntity>>, value: any): this;
        orWhere(record: Record<string, any>): this;
        orWhere(callback: (builder: QueryBuilder) => void): this;
        orWhere(raw: Raw): this;
        orWhereIn(
            column: ColumnRef<EntitySchema<TEntity>>,
            values: readonly any[] | QueryBuilder<any, any>,
        ): this;
        orWhereNotIn(
            column: ColumnRef<EntitySchema<TEntity>>,
            values: readonly any[] | QueryBuilder<any, any>,
        ): this;
        orWhereNotNull(column: ColumnRef<EntitySchema<TEntity>>): this;
        orWhereNull(column: ColumnRef<EntitySchema<TEntity>>): this;
        paginate(
            opts: { page: number; pageSize: number },
        ): Promise<
            PaginationResult<ExtractBranch<EntityResultByVariant<TEntity>, K>>,
        >;
        paginateAfter(
            opts: {
                column?: ColumnRef<EntitySchema<TEntity>>;
                cursor?: any;
                direction?: "asc" | "desc";
                limit: number;
            },
        ): Promise<
            CursorPaginationResult<
                ExtractBranch<EntityResultByVariant<TEntity>, K>,
            >,
        >;
        pluck<K extends string>(
            column: ColumnRef<EntitySchema<TEntity>>,
        ): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[K][]>;
        projected<K extends string>(
            name: K,
        ): SchemaQueryBuilder<
            EntitySchema<TEntity>,
            Pick<
                ExtractBranch<EntityResultByVariant<TEntity>, K>,
                ProjectionKeysOf<EntitySchema<TEntity>, K> & keyof ExtractBranch<
                    EntityResultByVariant<TEntity>,
                    K,
                >,
            >,
        >;
        restore(): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>[]>;
        scoped<K extends never>(name: K): this;
        select(...columns: (Raw<any> | ColumnRef<EntitySchema<TEntity>>)[]): this;
        select<TSel extends SelectSelector<EntitySchema<TEntity>>>(
            selector: TSel,
        ): SchemaQueryBuilder<
            EntitySchema<TEntity>,
            SelectProjection<ReturnType<TSel>>,
        >;
        selectRaw(sql: string, bindings?: any[]): this;
        selectVariants(keys: string[]): this;
        sum(column: Raw<any> | ColumnRef<EntitySchema<TEntity>>): this;
        then<
            TReturn1 = ExtractBranch<EntityResultByVariant<TEntity>, K>[],
            TReturn2 = never,
        >(
            onfulfilled?:
                | (
                    (
                        value: ExtractBranch<EntityResultByVariant<TEntity>, K>[],
                    ) => TReturn1 | PromiseLike<TReturn1>
                )
                | null,
            onrejected?: ((reason: any) => TReturn2 | PromiseLike<TReturn2>) | null,
        ): Promise<TReturn1 | TReturn2>;
        toKnexQuery(): QueryBuilder;
        toQuery(): string;
        toString(): string;
        transacting(
            trx: Transaction,
        ): SchemaQueryBuilder<
            EntitySchema<TEntity>,
            ExtractBranch<EntityResultByVariant<TEntity>, K>,
        >;
        unscoped(): this;
        update(patch: VariantUpdatePayload<TEntity, K>): Promise<void>;
        upsert(
            data: InferType<
                ReturnType<EntitySchema<TEntity>["makeAllPropsOptional"]>,
            >,
            opts: {
                conflictColumns: ColumnRef<EntitySchema<TEntity>>[];
                updateColumns?: ColumnRef<EntitySchema<TEntity>>[];
            },
        ): Promise<ExtractBranch<EntityResultByVariant<TEntity>, K>>;
        where(
            column: ColumnRef<EntitySchema<TEntity>>,
            operator: string,
            value: any,
        ): this;
        where(column: ColumnRef<EntitySchema<TEntity>>, value: any): this;
        where(raw: Raw, operator: string, value: any): this;
        where(callback: (builder: QueryBuilder) => void): this;
        where(record: Record<string, any>): this;
        where(raw: Raw): this;
        whereBetween(
            column: ColumnRef<EntitySchema<TEntity>>,
            range: readonly [any, any],
        ): this;
        whereExists(
            callback: QueryBuilder<any, any> | QueryCallback<any, unknown[]>,
        ): this;
        whereILike(column: ColumnRef<EntitySchema<TEntity>>, value: string): this;
        whereIn(
            column: ColumnRef<EntitySchema<TEntity>>,
            values: readonly any[] | QueryBuilder<any, any>,
        ): this;
        whereJsonPath(
            column: ColumnRef<EntitySchema<TEntity>>,
            path: string,
            operator?: string,
            value?: any,
        ): this;
        whereLike(column: ColumnRef<EntitySchema<TEntity>>, value: string): this;
        whereNot(
            column: ColumnRef<EntitySchema<TEntity>>,
            operator: string,
            value: any,
        ): this;
        whereNot(column: ColumnRef<EntitySchema<TEntity>>, value: any): this;
        whereNot(record: Record<string, any>): this;
        whereNot(callback: (builder: QueryBuilder) => void): this;
        whereNot(raw: Raw): this;
        whereNotBetween(
            column: ColumnRef<EntitySchema<TEntity>>,
            range: readonly [any, any],
        ): this;
        whereNotExists(
            callback: QueryBuilder<any, any> | QueryCallback<any, unknown[]>,
        ): this;
        whereNotIn(
            column: ColumnRef<EntitySchema<TEntity>>,
            values: readonly any[] | QueryBuilder<any, any>,
        ): this;
        whereNotNull(column: ColumnRef<EntitySchema<TEntity>>): this;
        whereNull(column: ColumnRef<EntitySchema<TEntity>>): this;
        whereRaw(sql: string, ...bindings: any[]): this;
        whereVariant(
            key: string,
            column: string,
            operator: string,
            value: any,
        ): this;
        withDeleted(): this;
        withTransaction(trx: Transaction): VariantDbSet<TEntity, K>;
    }

    Type Parameters

    • TEntity extends Entity<any, any, any>
    • K extends string

    Hierarchy

    Index

    Methods

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      • record: Record<string, any>

      Returns this

    • Parameters

      • callback: (builder: QueryBuilder) => void

      Returns this

    • Parameters

      • raw: Raw

      Returns this

    • Parameters

      • fn: (builder: QueryBuilder) => void

      Returns this

    • Parameters

      Returns Promise<number>

    • Delete rows matched by the current WHERE clause (CTI: atomic).

      Returns Promise<void>

    • Parameters

      • sql: string
      • ...bindings: any[]

      Returns this

    • Returns Promise<number>

    • Parameters

      Returns this

    • Parameters

      • sql: string
      • ...bindings: any[]

      Returns this

    • Parameters

      • n: number

      Returns this

    • Parameters

      • n: number

      Returns this

    • Returns this

    • Parameters

      Returns this

    • Parameters

      • sql: string
      • ...bindings: any[]

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      • record: Record<string, any>

      Returns this

    • Parameters

      • callback: (builder: QueryBuilder) => void

      Returns this

    • Parameters

      • raw: Raw

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Type Parameters

      • K extends never

      Parameters

      • name: K

      Returns this

    • Parameters

      • sql: string
      • Optionalbindings: any[]

      Returns this

    • Parameters

      • keys: string[]

      Returns this

    • Returns QueryBuilder

    • Returns string

    • Returns string

    • Returns this

    • Parameters

      Returns this

    • Parameters

      • callback: QueryBuilder<any, any> | QueryCallback<any, unknown[]>

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      • record: Record<string, any>

      Returns this

    • Parameters

      • callback: (builder: QueryBuilder) => void

      Returns this

    • Parameters

      • raw: Raw

      Returns this

    • Parameters

      Returns this

    • Parameters

      • callback: QueryBuilder<any, any> | QueryCallback<any, unknown[]>

      Returns this

    • Parameters

      Returns this

    • Parameters

      • sql: string
      • ...bindings: any[]

      Returns this

    • Parameters

      • key: string
      • column: string
      • operator: string
      • value: any

      Returns this

    • Returns this