@qualithm/arrow-flight-sql-js - v0.4.3
    Preparing search index...

    Class QueryBuilder

    Fluent SQL query builder.

    Supports SELECT, INSERT, UPDATE, and DELETE operations with a chainable API.

    const sql = new QueryBuilder()
    .select("id", "name")
    .from("users")
    .where("active", "=", true)
    .limit(10)
    .build()
    const sql = new QueryBuilder()
    .insertInto("users")
    .columns("name", "email")
    .values("Alice", "alice@example.com")
    .build()
    const sql = new QueryBuilder()
    .update("users")
    .set("status", "inactive")
    .where("last_login", "<", new Date("2024-01-01"))
    .build()
    const sql = new QueryBuilder()
    .deleteFrom("users")
    .where("status", "=", "deleted")
    .build()
    Index

    Constructors

    Methods

    • Build the SQL query string.

      Returns string

      The complete SQL query string

    • Build query with parameter placeholders for prepared statements.

      Returns BuiltQuery

      Object containing SQL with placeholders and parameter values

    • Specify columns for INSERT.

      Parameters

      • ...columns: string[]

      Returns this

    • Start a DELETE statement.

      Parameters

      • table: string

        Table to delete from

      Returns this

    • Specify the table to query from.

      Parameters

      • table: string

        Table name

      • Optionalalias: string

        Optional table alias

      Returns this

    • Add GROUP BY columns.

      Parameters

      • ...columns: string[]

      Returns this

    • Add an INNER JOIN clause.

      Parameters

      • table: string
      • on: string
      • Optionalalias: string

      Returns this

    • Start an INSERT statement.

      Parameters

      • table: string

        Table to insert into

      Returns this

    • Add a JOIN clause.

      Parameters

      • type: JoinType

        Join type (INNER, LEFT, RIGHT, FULL, CROSS)

      • table: string

        Table to join

      • on: string

        Join condition

      • Optionalalias: string

        Optional table alias

      Returns this

    • Add a LEFT JOIN clause.

      Parameters

      • table: string
      • on: string
      • Optionalalias: string

      Returns this

    • Set the maximum number of rows to return.

      Parameters

      • count: number

      Returns this

    • Set the number of rows to skip.

      Parameters

      • count: number

      Returns this

    • Add ORDER BY clause.

      Parameters

      • column: string

        Column to order by

      • direction: SortDirection = "ASC"

        Sort direction (ASC or DESC)

      • Optionalnulls: "FIRST" | "LAST"

        NULLS FIRST or NULLS LAST

      Returns this

    • Add a RIGHT JOIN clause.

      Parameters

      • table: string
      • on: string
      • Optionalalias: string

      Returns this

    • Specify columns to select.

      Parameters

      • ...columns: ColumnSpec[]

        Column names or column specs with aliases

      Returns this

      this for chaining

      .select("id", "name")
      .select({ column: "email", alias: "user_email" })
      .select("*")
    • Set a column value for UPDATE.

      Parameters

      • column: string

        Column to update

      • value: SqlValue

        New value

      Returns this

    • Set multiple column values for UPDATE.

      Parameters

      • values: Record<string, SqlValue>

        Object mapping column names to values

      Returns this

    • Start an UPDATE statement.

      Parameters

      • table: string

        Table to update

      Returns this

    • Add values to INSERT. Can be called multiple times for multi-row inserts.

      Parameters

      • ...values: SqlValue[]

        Values corresponding to columns

      Returns this

    • Add a WHERE condition.

      Parameters

      Returns this

      .where("status", "=", "active")
      .where("age", ">=", 18)
      .where("role", "IN", ["admin", "moderator"])
      .where("deleted_at", "IS", null)
    • Add a WHERE IS NOT NULL condition.

      Parameters

      • column: string

      Returns this

    • Add a WHERE IS NULL condition.

      Parameters

      • column: string

      Returns this