Iskra API Reference
    Preparing search index...

    Class OracleDriver<DB>

    Oracle Database for Iskra: a node-oracledb pool (Thin mode, no Oracle Client) in the app's process, typed queries with Kysely (db), raw SQL with typed binds (query, execute), transactions, pagination and migrations. Configured by app.config.oracle, or ORA_CONN, ORA_USER and ORA_PASSWORD; without either it does not start.

    Type Parameters

    • DB = Record<string, never>

    Implements

    Index
    db: Kysely<DB> | undefined

    Kysely over the pool, typed by DB; set by start().

    name: string = 'OracleDriver'
    serverVersion: number | undefined

    The server's major version (19, 21, 23…), known after start().

    • Opens a standalone connection (for migrations); tests replace it.

      Parameters

      • attributes: Record<string, unknown>

      Returns Promise<OracleConnectionLike>

    • Creates the pool; tests replace it with a fake one.

      Parameters

      • attributes: Record<string, unknown>

      Returns Promise<OraclePoolLike>

    • Runs a statement: rows, rowsAffected and outBinds. Binds by name may give a type by name: { id: { dir: 'returning', type: 'number' } } for RETURNING id INTO :id, { dir: 'out', type: 'string' } for a PL/SQL OUT parameter, { type: 'clob', val: text } for a long IN value. Outside a transaction it commits on its own; inside transaction() it runs in the transaction.

      Type Parameters

      Parameters

      Returns Promise<ExecuteResult<T, OutBinds<B>>>

    • Parameters

      Returns Promise<void>

    • A page of a query's rows and its counts: SQL with params by name, or a function of the filters and orders; offset/limit or page/pageSize.

      const page = await oracle.list({
      query: (filters, orders) => usuariosQuery(filters, orders), // { sql, params }
      filters, orders, totalFilters: {},
      offset: c.req.query('start'), limit: c.req.query('length'),
      rows: Usuario,
      }); // { rows, total, filtered, offset, limit, pages }

      Type Parameters

      • T = Record<string, unknown>
      • F = unknown
      • O = unknown

      Parameters

      Returns Promise<ListResult<T>>

    • The first row of a query, or a NoRowsError (NOT_FOUND: web-kit answers 404).

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<T>

    • Adds a callback for every statement, commit and rollback, besides the others (a tracer and a logger each keep their own); returns what removes it. See OnQueryHook.

      Parameters

      Returns () => void

    • One page of a Kysely query and its total: see paginate().

      Type Parameters

      • TB extends string | number | symbol
      • O

      Parameters

      Returns Promise<Page<O>>

    • SELECT 1 FROM DUAL for readiness checks: true or false within pingTimeout (default 5 s), never throws. A ping still waiting for a connection is shared by the next ones instead of queueing more.

      Returns Promise<boolean>

    • The rows of a query, decoded by options.rows when given.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<T[]>

    • The first row of a query (fetching only that one), or undefined.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<T | undefined>

    • Applies the pending .sql migrations of dir (default ./migrations) and returns their names. Needs start(). Its statements have no callTimeout: building an index may take long.

      Parameters

      Returns Promise<string[]>

    • Register a callback for every statement and its binds (raw and Kysely); it may return a function called when the statement ends (see OnQueryHook). A throwing callback is ignored: observability never fails a query.

      Parameters

      Returns void

    • Returns Promise<void>

    • Returns Promise<void>

    • The rows of a query one at a time, fetched chunkSize (default 100) at a time.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns AsyncGenerator<T>

    • Runs fn on one connection with autoCommit off, and commits when it returns or rolls back when it throws (rethrowing its error). Inside it, oracle.query(), oracle.execute(), oracle.db… also run in the transaction (another connection could wait forever on its locks); opening another transaction() throws.

      Type Parameters

      • R

      Parameters

      Returns Promise<R>