expo-sqlite
Advanced tools
Comparing version
import './polyfillNextTick'; | ||
declare type InternalResultSet = { | ||
export declare type Query = { | ||
sql: string; | ||
args: unknown[]; | ||
}; | ||
export interface ResultSetError { | ||
error: Error; | ||
} | { | ||
} | ||
export interface ResultSet { | ||
insertId?: number; | ||
@@ -10,6 +15,8 @@ rowsAffected: number; | ||
}>; | ||
}; | ||
export declare type SQLiteCallback = (error?: Error | null, resultSet?: InternalResultSet) => void; | ||
} | ||
export declare type SQLiteCallback = (error?: Error | null, resultSet?: Array<ResultSetError | ResultSet>) => void; | ||
export declare function openDatabase(name: string, version?: string, description?: string, size?: number, callback?: (db: WebSQLDatabase) => void): WebSQLDatabase; | ||
declare type WebSQLDatabase = unknown; | ||
export interface WebSQLDatabase { | ||
exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void; | ||
} | ||
declare const _default: { | ||
@@ -16,0 +23,0 @@ openDatabase: typeof openDatabase; |
@@ -7,2 +7,4 @@ import './polyfillNextTick'; | ||
const { ExponentSQLite } = NativeModulesProxy; | ||
; | ||
; | ||
class SQLiteDatabase { | ||
@@ -9,0 +11,0 @@ constructor(name) { |
{ | ||
"name": "expo-sqlite", | ||
"version": "5.0.1", | ||
"version": "6.0.0-rc.0", | ||
"description": "Provides access to a database that can be queried through a WebSQL-like API (https://www.w3.org/TR/webdatabase/). The database is persisted across restarts of your app.", | ||
@@ -47,3 +47,3 @@ "main": "build/index.js", | ||
}, | ||
"gitHead": "f213c9be2a909dae42a0a27d8aa4b9eac8e97be1" | ||
} | ||
"gitHead": "6334f82adccb529e9347e348c874bd8f6a92cacc" | ||
} |
@@ -10,13 +10,14 @@ import './polyfillNextTick'; | ||
type InternalQuery = { sql: string; args: unknown[] }; | ||
export type Query = { sql: string; args: unknown[] }; | ||
type InternalResultSet = | ||
| { error: Error } | ||
| { | ||
insertId?: number; | ||
rowsAffected: number; | ||
rows: Array<{ [column: string]: any }>; | ||
}; | ||
export interface ResultSetError { | ||
error: Error; | ||
}; | ||
export interface ResultSet { | ||
insertId?: number; | ||
rowsAffected: number; | ||
rows: Array<{ [column: string]: any }>; | ||
}; | ||
export type SQLiteCallback = (error?: Error | null, resultSet?: InternalResultSet) => void; | ||
export type SQLiteCallback = (error?: Error | null, resultSet?: Array<ResultSetError | ResultSet>) => void; | ||
@@ -31,3 +32,3 @@ class SQLiteDatabase { | ||
exec(queries: InternalQuery[], readOnly: boolean, callback: SQLiteCallback): void { | ||
exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void { | ||
if (this._closed) { | ||
@@ -54,7 +55,7 @@ throw new Error(`The SQLite database is closed`); | ||
function _serializeQuery(query: InternalQuery): [string, unknown[]] { | ||
function _serializeQuery(query: Query): [string, unknown[]] { | ||
return [query.sql, Platform.OS === 'android' ? query.args.map(_escapeBlob) : query.args]; | ||
} | ||
function _deserializeResultSet(nativeResult): InternalResultSet { | ||
function _deserializeResultSet(nativeResult): ResultSet | ResultSetError { | ||
let [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult; | ||
@@ -64,3 +65,3 @@ // TODO: send more structured error information from the native module so we can better construct | ||
if (errorMessage !== null) { | ||
return { error: new Error(errorMessage) }; | ||
return { error: new Error(errorMessage) } as ResultSetError; | ||
} | ||
@@ -91,3 +92,3 @@ | ||
function addExecMethod(db: any): WebSQLDatabase { | ||
db.exec = (queries: InternalQuery[], readOnly: boolean, callback: SQLiteCallback): void => { | ||
db.exec = (queries: Query[], readOnly: boolean, callback: SQLiteCallback): void => { | ||
db._db.exec(queries, readOnly, callback); | ||
@@ -113,3 +114,5 @@ } | ||
type WebSQLDatabase = unknown; | ||
export interface WebSQLDatabase { | ||
exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void; | ||
} | ||
@@ -116,0 +119,0 @@ export default { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39638
2.13%31
3.33%584
4.29%0
-100%1
Infinity%