Skip to content

Instantly share code, notes, and snippets.

@calebergh
Created July 14, 2023 19:23
Show Gist options
  • Save calebergh/c31c8b0e9fca04fe8da2914f8c03a221 to your computer and use it in GitHub Desktop.
Save calebergh/c31c8b0e9fca04fe8da2914f8c03a221 to your computer and use it in GitHub Desktop.
nativescript-sqlite types
// Based on official docs: https://github.com/NathanaelA/nativescript-sqlite/blob/master/src/README.md
interface SQLLite {
isOpen: () => boolean;
isSqlite: (db: any) => boolean;
exists: (dbName: string) => boolean;
deleteDatabase: (dbName: string) => boolean;
copyDatabase: (dbName: string, destName: string) => boolean;
version: (version?: number) => Promise<number>;
close: () => Promise<any>;
execSQL: (sql: string, params?: Array<string | number | null>, cb?: () => {}) => Promise<number>;
get: <T extends DBRecord>(sql: string, params?: Array<string | number | null>, cb?: () => {}) => Promise<[T]>;
all: <T extends DBRecord>(sql: string, params?: Array<string | number | null>, cb?: () => {}) => Promise<Array<T>>;
each: <T extends DBRecord>(sql: string, params?: Array<string | number | null>, cb?: (err, row) => {/* iterates per row */}) => Promise<number>;
// set the result type - see constants such as RESULTSASOBJECT
resultType: (number) => {};
// set the result type - see constants such as VALUESARESTRING
valueType: (number) => {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment