Skip to content

Commit 5e0fdc4

Browse files
committed
re-structure index
1 parent e931a5a commit 5e0fdc4

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

package/src/index.ts

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/prefer-optional-chain */
21
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
32
/* eslint-disable no-var */
43
/* eslint-disable @typescript-eslint/no-unsafe-argument */
@@ -11,22 +10,21 @@
1110
import RNQuickSQLiteModule from './NativeRNQuickSQLiteModule'
1211

1312
declare global {
14-
function nativeCallSyncHook(): unknown
1513
var __QuickSQLiteProxy: object | undefined
1614
}
1715

1816
if (global.__QuickSQLiteProxy == null) {
19-
if (RNQuickSQLiteModule == null || RNQuickSQLiteModule.install == null) {
17+
if (RNQuickSQLiteModule == null) {
2018
throw new Error(
21-
'QuickSQLite TurboModule not found. Maybe try rebuilding the app.'
19+
'RNQuickSQLite TurboModule not found. Maybe try rebuilding the app.'
2220
)
2321
}
2422

2523
// Call the synchronous blocking install() function
2624
const result = RNQuickSQLiteModule.install()
2725
if (result !== true) {
2826
throw new Error(
29-
`Failed to install react-native-quick-sqlite: The QuickSQLite TurboModule could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
27+
`Failed to install react-native-quick-sqlite: The RNQuickSQLite TurboModule could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
3028
)
3129
}
3230

@@ -39,6 +37,36 @@ if (global.__QuickSQLiteProxy == null) {
3937
}
4038
export const QuickSQLite = global.__QuickSQLiteProxy as ISQLite
4139

40+
interface ISQLite {
41+
open: (dbName: string, location?: string) => void
42+
close: (dbName: string) => void
43+
delete: (dbName: string, location?: string) => void
44+
attach: (
45+
mainDbName: string,
46+
dbNameToAttach: string,
47+
alias: string,
48+
location?: string
49+
) => void
50+
detach: (mainDbName: string, alias: string) => void
51+
transaction: (
52+
dbName: string,
53+
fn: (tx: Transaction) => Promise<void> | void
54+
) => Promise<void>
55+
execute: (dbName: string, query: string, params?: any[]) => QueryResult
56+
executeAsync: (
57+
dbName: string,
58+
query: string,
59+
params?: any[]
60+
) => Promise<QueryResult>
61+
executeBatch: (dbName: string, commands: SQLBatchTuple[]) => BatchQueryResult
62+
executeBatchAsync: (
63+
dbName: string,
64+
commands: SQLBatchTuple[]
65+
) => Promise<BatchQueryResult>
66+
loadFile: (dbName: string, location: string) => FileLoadResult
67+
loadFileAsync: (dbName: string, location: string) => Promise<FileLoadResult>
68+
}
69+
4270
/**
4371
* Object returned by SQL Query executions {
4472
* insertId: Represent the auto-generated row id if applicable
@@ -131,36 +159,6 @@ export interface PendingTransaction {
131159
start: () => void
132160
}
133161

134-
interface ISQLite {
135-
open: (dbName: string, location?: string) => void
136-
close: (dbName: string) => void
137-
delete: (dbName: string, location?: string) => void
138-
attach: (
139-
mainDbName: string,
140-
dbNameToAttach: string,
141-
alias: string,
142-
location?: string
143-
) => void
144-
detach: (mainDbName: string, alias: string) => void
145-
transaction: (
146-
dbName: string,
147-
fn: (tx: Transaction) => Promise<void> | void
148-
) => Promise<void>
149-
execute: (dbName: string, query: string, params?: any[]) => QueryResult
150-
executeAsync: (
151-
dbName: string,
152-
query: string,
153-
params?: any[]
154-
) => Promise<QueryResult>
155-
executeBatch: (dbName: string, commands: SQLBatchTuple[]) => BatchQueryResult
156-
executeBatchAsync: (
157-
dbName: string,
158-
commands: SQLBatchTuple[]
159-
) => Promise<BatchQueryResult>
160-
loadFile: (dbName: string, location: string) => FileLoadResult
161-
loadFileAsync: (dbName: string, location: string) => Promise<FileLoadResult>
162-
}
163-
164162
const locks: Record<
165163
string,
166164
{ queue: PendingTransaction[]; inProgress: boolean }

0 commit comments

Comments
 (0)