Skip to content

Commit 573221c

Browse files
authored
Exposes flushPendingReactiveQueries (#344)
1 parent b09da38 commit 573221c

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/functions.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ function enhanceDB(db: _InternalDB, options: DBParams): DB {
9494
delete: db.delete,
9595
attach: db.attach,
9696
detach: db.detach,
97+
loadFile: db.loadFile,
98+
updateHook: db.updateHook,
99+
commitHook: db.commitHook,
100+
rollbackHook: db.rollbackHook,
101+
loadExtension: db.loadExtension,
102+
getDbPath: db.getDbPath,
103+
reactiveExecute: db.reactiveExecute,
104+
sync: db.sync,
105+
setReservedBytes: db.setReservedBytes,
106+
getReservedBytes: db.getReservedBytes,
107+
close: db.close,
108+
flushPendingReactiveQueries: db.flushPendingReactiveQueries,
97109
executeBatch: async (
98110
commands: SQLBatchTuple[]
99111
): Promise<BatchQueryResult> => {
@@ -141,17 +153,6 @@ function enhanceDB(db: _InternalDB, options: DBParams): DB {
141153
startNextTransaction();
142154
});
143155
},
144-
loadFile: db.loadFile,
145-
updateHook: db.updateHook,
146-
commitHook: db.commitHook,
147-
rollbackHook: db.rollbackHook,
148-
loadExtension: db.loadExtension,
149-
getDbPath: db.getDbPath,
150-
reactiveExecute: db.reactiveExecute,
151-
sync: db.sync,
152-
setReservedBytes: db.setReservedBytes,
153-
getReservedBytes: db.getReservedBytes,
154-
close: db.close,
155156
executeWithHostObjects: async (
156157
query: string,
157158
params?: Scalar[]

src/types.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ export type DB = {
294294
sync: () => void;
295295
setReservedBytes: (reservedBytes: number) => void;
296296
getReservedBytes: () => number;
297+
/**
298+
* If you have changed any of the tables outside of a transaction then the reactive queries will not fire on their own
299+
* This method allows to flush the pending queue of changes. Useful when using Drizzle or other ORM that do not
300+
* use the db.transaction method internally
301+
* @returns void
302+
*/
303+
flushPendingReactiveQueries: () => Promise<void>;
297304
};
298305

299306
export type DBParams = {
@@ -310,10 +317,7 @@ export type OPSQLiteProxy = {
310317
location?: string;
311318
encryptionKey?: string;
312319
}) => _InternalDB;
313-
openV2: (options: {
314-
path: string;
315-
encryptionKey?: string
316-
}) => _InternalDB,
320+
openV2: (options: { path: string; encryptionKey?: string }) => _InternalDB;
317321
openRemote: (options: { url: string; authToken: string }) => _InternalDB;
318322
openSync: (options: DBParams) => _InternalDB;
319323
isSQLCipher: () => boolean;

0 commit comments

Comments
 (0)