UNPKG

sqlite3orm

Version:

ORM for sqlite3 and TypeScript/JavaScript

72 lines (71 loc) 2.17 kB
import { Statement } from 'sqlite3'; export interface SqlRunResult { lastID: number; changes: number; } /** * A thin wrapper for the 'Statement' class from 'node-sqlite3' using Promises instead of callbacks * see * https://github.com/mapbox/node-sqlite3/wiki/API * * @export * @class SqlStatement */ export declare class SqlStatement { private readonly stmt; /** * Creates an instance of SqlStatement. * * @param stmt */ constructor(stmt: Statement); /** * Bind the given parameters to the prepared statement * * @param params */ bind(...params: any[]): this; /** * Reset a open cursor of the prepared statement preserving the parameter binding * Allows re-execute of the same query * * @returns {Promise<void>} */ reset(): Promise<void>; /** * Finalizes a prepared statement ( freeing any resource used by this statement ) * * @returns {Promise<void>} */ finalize(): Promise<void>; /** * Runs a prepared statement with the specified parameters * * @param [params] - The parameters referenced in the statement; you can provide multiple parameters as array * @returns A promise */ run(params?: any): Promise<SqlRunResult>; /** * Runs a prepared statement with the specified parameters, fetching only the first row * * @param [params] - The parameters referenced in the statement; you can provide multiple parameters as array * @returns A promise */ get(params?: any): Promise<any>; /** * Runs a prepared statement with the specified parameters, fetching all rows * * @param [params] - The parameters referenced in the statement; you can provide multiple parameters as array * @returns A promise */ all(params?: any): Promise<any[]>; /** * Runs a prepared statement with the specified parameters, fetching all rows * using a callback for each row * * @param [params] * @param [callback] * @returns A promise */ each(params?: any, callback?: (err: Error, row: any) => void): Promise<number>; }