All files / src/interfaces Sqlite3.interfaces.ts

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77  3x                 3x                                                     3x 3x 3x 3x                                                                        
/* eslint-disable */
import * as sqlite from 'sqlite3'
import { SQLStatement } from 'sql-template-strings'
import { Sqlite3Statement } from '../sqlite3/Sqlite3Statement'
 
export interface SqlObj {
  sql: string
  params?: any[]
}
 
export namespace Sqlite3 {
  export type SqlType = SQLStatement | string
 
  export interface Config {
    /**
     * Valid values are filenames, ":memory:" for an anonymous in-memory
     * database and an empty string for an anonymous disk-based database.
     * Anonymous databases are not persisted and when closing the database
     * handle, their contents are lost.
     */
    filename: string
 
    /**
     * One or more of sqlite3.OPEN_READONLY, sqlite3.OPEN_READWRITE and
     * sqlite3.OPEN_CREATE. The default value is OPEN_READWRITE | OPEN_CREATE.
     */
    mode?: OpenDatabaseEnum
  }
 
  export interface DatabaseConfigParams extends Config {
    /**
     * Use an alternative library instead of sqlite3. The interface of the library must
     * conform to sqlite3.
     */
    driver: any
  }
 
  export enum OpenDatabaseEnum {
    OPEN_READONLY = sqlite.OPEN_READONLY,
    OPEN_READWRITE = sqlite.OPEN_READWRITE,
    OPEN_CREATE = sqlite.OPEN_CREATE
  }
 
  export type ConfigureOption = 'trace' | 'profile' | 'busyTimeout'
 
  export interface RunResult {
    /**
     * Statement object.
     *
     * It is not possible to run the statement again because it is
     * automatically finalized after running for the first time.
     * Any subsequent attempts to run the statement again will fail.
     */
    stmt: Sqlite3Statement
    /**
     * Row id of the inserted row.
     *
     * Only contains valid information when the query was a successfully
     * completed INSERT statement.
     */
    lastID?: number
    /**
     * Number of rows changed.
     *
     * Only contains valid information when the query was a
     * successfully completed UPDATE or DELETE statement.
     */
    changes?: number
  }
}
 
declare module 'sqlite3' {
  interface Database {
    loadExtension(path: string, callback?: (err) => void)
  }
}