@w0s/sqlite-utility
v2.0.0
Published
SQLite Utilities
Readme
SQLite utility
Examples
import { jsToSQLiteComparison, jsToSQLiteAssignment, sqliteToJS, prepareSelect, prepareInsert, prepareUpdate, prepareDelete } from '@w0s/sqlite-utility';
jsToSQLiteComparison('text'); // 'text'
jsToSQLiteComparison(123); // 123
jsToSQLiteComparison(true); // 1
jsToSQLiteComparison(false); // 0
jsToSQLiteComparison(new Date('2000-01-01')); // 946684800
jsToSQLiteComparison(new URL('http://example.com/foo?bar#baz')); // 'http://example.com/foo?bar#baz'
jsToSQLiteAssignment('text'); // 'text'
...
jsToSQLiteAssignment(undefined); // null
sqliteToJS('text'); // 'text'
sqliteToJS(123); // 123
sqliteToJS(0, 'boolean'); // false
sqliteToJS(1, 'boolean'); // true
try {
sqliteToJS(2, 'boolean'); // Error
} catch {
}
sqliteToJS(946684800, 'date'); // `Date` object
try {
sqliteToJS(1.2, 'date'); // Error
} catch {
}
sqliteToJS('http://example.com/foo?bar#baz', 'url'); // `URL` interface
try {
sqliteToJS(123, 'url'); // Error
} catch {
}
sqliteToJS(null); // undefinedFunctions
type JSType = string | number | boolean | Date | URL | undefined;
type SQLiteType = string | number | null;