tormenta20 - v0.0.0
    Preparing search index...

    Class Query<T>

    Immutable chainable query builder over a SQLite table.

    Every method that filters or sorts returns a new Query instance, so the original is never mutated. Call a terminal method (all, first, last, find, count, exists) to execute the query.

    Arma.query()
    .where("category = ?", "marciais")
    .order("name")
    .limit(10)
    .all()

    Type Parameters

    • T

      The model class this query resolves to.

    Index

    Constructors

    • Type Parameters

      • T

        The model class this query resolves to.

      Parameters

      • table: string
      • deserialize: (row: Record<string, unknown>) => T
      • wheres: string[] = []
      • params: unknown[] = []
      • order: string | null = null
      • limit: number | null = null

      Returns Query<T>

    Methods

    • Executes the query and returns all matching records.

      Returns T[]

      Array of model instances (empty array if none found)

    • Counts the rows matching the current filters.

      Returns number

      Number of matching records

    • Returns true if at least one record matches the current filters.

      Returns boolean

    • Looks up a single record by its id column.

      Parameters

      • id: string

        The unique string identifier

      Returns T | null

      The matching record, or null if not found

    • Returns the first record by insertion order, or null if none found.

      Returns T | null

    • Returns the last record by insertion order, or null if none found.

      Returns T | null

    • Sets a LIMIT on the number of rows returned.

      Parameters

      • n: number

        Maximum number of results

      Returns Query<T>

      A new Query with the limit applied

    • Sets the ORDER BY clause.

      Parameters

      • field: string

        Column name to sort by

      • dir: "ASC" | "DESC" = "ASC"

        Sort direction (default "ASC")

      Returns Query<T>

      A new Query with the ordering applied

    • Adds a WHERE clause using a parameterised SQL fragment.

      Multiple calls are combined with AND.

      Parameters

      • sql: string

        SQL fragment with ? placeholders (e.g. "category = ?")

      • ...p: unknown[]

        Values bound to each ? in order

      Returns Query<T>

      A new Query with the clause appended

      Magia.query().where("circle = ?", "3").where("type = ?", "arcana").all()