Documentation
    Preparing search index...

    Class SQLiteDeleteBase<TTable, TResultType, TRunResult, TReturning, TDynamic, TExcludedMethods>

    Type Parameters

    • TTable extends SQLiteTable
    • TResultType extends "sync" | "async"
    • TRunResult
    • TReturning extends Record<string, unknown> | undefined = undefined
    • TDynamic extends boolean = false
    • TExcludedMethods extends string = never

    Hierarchy

    Implements

    Index

    Constructors

    Properties

    _: {
        dialect: "sqlite";
        dynamic: TDynamic;
        excludedMethods: TExcludedMethods;
        result: TReturning extends undefined ? TRunResult : TReturning[];
        resultType: TResultType;
        returning: TReturning;
        runResult: TRunResult;
        table: TTable;
    }
    "[toStringTag]": string
    all: (
        placeholderValues?: Record<string, unknown>,
    ) => Result<
        TResultType,
        TReturning extends undefined
            ? DrizzleTypeError<".all() cannot be used without .returning()">
            : TReturning[],
    >
    get: (
        placeholderValues?: Record<string, unknown>,
    ) => Result<
        TResultType,
        TReturning extends undefined
            ? DrizzleTypeError<".get() cannot be used without .returning()">
            : TReturning | undefined,
    >
    run: (
        placeholderValues?: Record<string, unknown>,
    ) => Result<TResultType, TRunResult>
    values: (
        placeholderValues?: Record<string, unknown>,
    ) => Result<
        TResultType,
        TReturning extends undefined
            ? DrizzleTypeError<".values() cannot be used without .returning()">
            : any[][],
    >
    "[entityKind]": string

    Methods

    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

      Parameters

      • OptionalonFinally: (() => void) | null

      Returns Promise<TReturning extends undefined ? TRunResult : TReturning[]>

      A Promise for the completion of the callback.

    • Adds a returning clause to the query.

      Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.

      See docs: https://orm.drizzle.team/docs/delete#delete-with-return

      Returns SQLiteDeleteWithout<
          SQLiteDeleteBase<
              TTable,
              TResultType,
              TRunResult,
              TTable["$inferSelect"],
              TDynamic,
              TExcludedMethods,
          >,
          TDynamic,
      >

      // Delete all cars with the green color and return all fields
      const deletedCars: Car[] = await db.delete(cars)
      .where(eq(cars.color, 'green'))
      .returning();

      // Delete all cars with the green color and return only their id and brand fields
      const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
      .where(eq(cars.color, 'green'))
      .returning({ id: cars.id, brand: cars.brand });
    • Adds a returning clause to the query.

      Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.

      See docs: https://orm.drizzle.team/docs/delete#delete-with-return

      Type Parameters

      Parameters

      Returns SQLiteDeleteWithout<
          SQLiteDeleteBase<
              TTable,
              TResultType,
              TRunResult,
              {
                  [K in string
                  | number
                  | symbol]: {
                      [Key in string | number | symbol]: SelectResultField<
                          TSelectedFields[Key],
                          true,
                      >
                  }[K]
              },
              TDynamic,
              TExcludedMethods,
          >,
          TDynamic,
          "returning",
      >

      // Delete all cars with the green color and return all fields
      const deletedCars: Car[] = await db.delete(cars)
      .where(eq(cars.color, 'green'))
      .returning();

      // Delete all cars with the green color and return only their id and brand fields
      const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
      .where(eq(cars.color, 'green'))
      .returning({ id: cars.id, brand: cars.brand });
    • Adds a where clause to the query.

      Calling this method will delete only those rows that fulfill a specified condition.

      See docs: https://orm.drizzle.team/docs/delete

      Parameters

      • where: SQL<unknown> | undefined

        the where clause.

      Returns SQLiteDeleteWithout<
          SQLiteDeleteBase<
              TTable,
              TResultType,
              TRunResult,
              TReturning,
              TDynamic,
              TExcludedMethods,
          >,
          TDynamic,
          "where",
      >

      You can use conditional operators and sql function to filter the rows to be deleted.

      // Delete all cars with green color
      db.delete(cars).where(eq(cars.color, 'green'));
      // or
      db.delete(cars).where(sql`${cars.color} = 'green'`)

      You can logically combine conditional operators with and() and or() operators:

      // Delete all BMW cars with a green color
      db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));

      // Delete all cars with the green or blue color
      db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));