Documentation
    Preparing search index...

    Class SQLiteSelectQueryBuilderBase<THKT, TTableName, TResultType, TRunResult, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>Abstract

    Type Parameters

    • THKT extends SQLiteSelectHKTBase
    • TTableName extends string | undefined
    • TResultType extends "sync" | "async"
    • TRunResult
    • TSelection extends ColumnsSelection
    • TSelectMode extends SelectMode
    • TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, "not-null"> : {}
    • TDynamic extends boolean = false
    • TExcludedMethods extends string = never
    • TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[]
    • TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _: {
        config: SQLiteSelectConfig;
        dialect: "sqlite";
        dynamic: TDynamic;
        excludedMethods: TExcludedMethods;
        hkt: THKT;
        nullabilityMap: TNullabilityMap;
        result: TResult;
        resultType: TResultType;
        runResult: TRunResult;
        selectedFields: TSelectedFields;
        selection: TSelection;
        selectMode: TSelectMode;
        tableName: TTableName;
    }
    cacheConfig?: WithCacheConfig
    crossJoin: SQLiteSelectCrossJoinFn<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
    >

    Executes a cross join operation by combining rows from two tables into a new table.

    Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.

    See docs: https://orm.drizzle.team/docs/joins#cross-join

    the table to join.

    // Select all users, each user with every pet
    const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
    .from(users)
    .crossJoin(pets)

    // Select userId and petId
    const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
    userId: users.id,
    petId: pets.id,
    })
    .from(users)
    .crossJoin(pets)
    dialect: SQLiteDialect
    except: <TValue extends SQLiteSetOperatorWithResult<TResult>>(
        rightSelection:
            | (
                (
                    setOperators: GetSQLiteSetOperators,
                ) => SetOperatorRightSelect<TValue, TResult>
            )
            | SetOperatorRightSelect<TValue, TResult>,
    ) => SQLiteSelectWithout<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        SQLiteSetOperatorExcludedMethods,
        true,
    >

    Adds except set operator to the query.

    Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.

    See docs: https://orm.drizzle.team/docs/set-operations#except

    // Select all courses offered in department A but not in department B
    await db.select({ courseName: depA.courseName })
    .from(depA)
    .except(
    db.select({ courseName: depB.courseName }).from(depB)
    );
    // or
    import { except } from 'drizzle-orm/sqlite-core'

    await except(
    db.select({ courseName: depA.courseName }).from(depA),
    db.select({ courseName: depB.courseName }).from(depB)
    );
    fullJoin: SQLiteSelectJoinFn<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        "full",
    >

    Executes a full join operation by combining rows from two tables into a new table.

    Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in null for non-matching columns.

    See docs: https://orm.drizzle.team/docs/joins#full-join

    the table to join.

    the on clause.

    // Select all users and their pets
    const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
    .from(users)
    .fullJoin(pets, eq(users.id, pets.ownerId))

    // Select userId and petId
    const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
    userId: users.id,
    petId: pets.id,
    })
    .from(users)
    .fullJoin(pets, eq(users.id, pets.ownerId))
    innerJoin: SQLiteSelectJoinFn<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        "inner",
    >

    Executes an inner join operation, creating a new table by combining rows from two tables that have matching values.

    Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.

    See docs: https://orm.drizzle.team/docs/joins#inner-join

    the table to join.

    the on clause.

    // Select all users and their pets
    const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
    .from(users)
    .innerJoin(pets, eq(users.id, pets.ownerId))

    // Select userId and petId
    const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
    userId: users.id,
    petId: pets.id,
    })
    .from(users)
    .innerJoin(pets, eq(users.id, pets.ownerId))
    intersect: <TValue extends SQLiteSetOperatorWithResult<TResult>>(
        rightSelection:
            | (
                (
                    setOperators: GetSQLiteSetOperators,
                ) => SetOperatorRightSelect<TValue, TResult>
            )
            | SetOperatorRightSelect<TValue, TResult>,
    ) => SQLiteSelectWithout<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        SQLiteSetOperatorExcludedMethods,
        true,
    >

    Adds intersect set operator to the query.

    Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.

    See docs: https://orm.drizzle.team/docs/set-operations#intersect

    // Select course names that are offered in both departments A and B
    await db.select({ courseName: depA.courseName })
    .from(depA)
    .intersect(
    db.select({ courseName: depB.courseName }).from(depB)
    );
    // or
    import { intersect } from 'drizzle-orm/sqlite-core'

    await intersect(
    db.select({ courseName: depA.courseName }).from(depA),
    db.select({ courseName: depB.courseName }).from(depB)
    );
    joinsNotNullableMap: Record<string, boolean>
    leftJoin: SQLiteSelectJoinFn<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        "left",
    >

    Executes a left join operation by adding another table to the current query.

    Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.

    See docs: https://orm.drizzle.team/docs/joins#left-join

    the table to join.

    the on clause.

    // Select all users and their pets
    const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
    .from(users)
    .leftJoin(pets, eq(users.id, pets.ownerId))

    // Select userId and petId
    const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
    userId: users.id,
    petId: pets.id,
    })
    .from(users)
    .leftJoin(pets, eq(users.id, pets.ownerId))
    rightJoin: SQLiteSelectJoinFn<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        "right",
    >

    Executes a right join operation by adding another table to the current query.

    Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.

    See docs: https://orm.drizzle.team/docs/joins#right-join

    the table to join.

    the on clause.

    // Select all users and their pets
    const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
    .from(users)
    .rightJoin(pets, eq(users.id, pets.ownerId))

    // Select userId and petId
    const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
    userId: users.id,
    petId: pets.id,
    })
    .from(users)
    .rightJoin(pets, eq(users.id, pets.ownerId))
    session: SQLiteSession<any, any, any, any> | undefined
    union: <TValue extends SQLiteSetOperatorWithResult<TResult>>(
        rightSelection:
            | (
                (
                    setOperators: GetSQLiteSetOperators,
                ) => SetOperatorRightSelect<TValue, TResult>
            )
            | SetOperatorRightSelect<TValue, TResult>,
    ) => SQLiteSelectWithout<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        SQLiteSetOperatorExcludedMethods,
        true,
    >

    Adds union set operator to the query.

    Calling this method will combine the result sets of the select statements and remove any duplicate rows that appear across them.

    See docs: https://orm.drizzle.team/docs/set-operations#union

    // Select all unique names from customers and users tables
    await db.select({ name: users.name })
    .from(users)
    .union(
    db.select({ name: customers.name }).from(customers)
    );
    // or
    import { union } from 'drizzle-orm/sqlite-core'

    await union(
    db.select({ name: users.name }).from(users),
    db.select({ name: customers.name }).from(customers)
    );
    unionAll: <TValue extends SQLiteSetOperatorWithResult<TResult>>(
        rightSelection:
            | (
                (
                    setOperators: GetSQLiteSetOperators,
                ) => SetOperatorRightSelect<TValue, TResult>
            )
            | SetOperatorRightSelect<TValue, TResult>,
    ) => SQLiteSelectWithout<
        SQLiteSelectQueryBuilderBase<
            THKT,
            TTableName,
            TResultType,
            TRunResult,
            TSelection,
            TSelectMode,
            TNullabilityMap,
            TDynamic,
            TExcludedMethods,
            TResult,
            TSelectedFields,
        >,
        TDynamic,
        SQLiteSetOperatorExcludedMethods,
        true,
    >

    Adds union all set operator to the query.

    Calling this method will combine the result-set of the select statements and keep all duplicate rows that appear across them.

    See docs: https://orm.drizzle.team/docs/set-operations#union-all

    // Select all transaction ids from both online and in-store sales
    await db.select({ transaction: onlineSales.transactionId })
    .from(onlineSales)
    .unionAll(
    db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
    );
    // or
    import { unionAll } from 'drizzle-orm/sqlite-core'

    await unionAll(
    db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
    db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
    );
    usedTables: Set<string>
    "[entityKind]": string

    Methods