@@ -25,7 +25,11 @@ export class RNQSDBAdapter extends BaseObserver<DBAdapterListener> implements DB
2525 this . iterateListeners ( ( cb ) => cb . tablesUpdated ?.( update ) ) ;
2626 } ) ;
2727
28- const topLevelUtils = this . generateDBHelpers ( { execute : this . readOnlyExecute } ) ;
28+ const topLevelUtils = this . generateDBHelpers ( {
29+ // Arrow function binds `this` for use in readOnlyExecute
30+ execute : ( sql : string , params ?: any [ ] ) => this . readOnlyExecute ( sql , params )
31+ } ) ;
32+ // Only assigning get helpers
2933 this . getAll = topLevelUtils . getAll ;
3034 this . getOptional = topLevelUtils . getOptional ;
3135 this . get = topLevelUtils . get ;
@@ -56,13 +60,13 @@ export class RNQSDBAdapter extends BaseObserver<DBAdapterListener> implements DB
5660 }
5761
5862 /**
59- * This provides a top-level read only execute method which is executed inside a read lock.
63+ * This provides a top-level read only execute method which is executed inside a read- lock.
6064 * This is necessary since the high level `execute` method uses a write-lock under
6165 * the hood. Helper methods such as `get`, `getAll` and `getOptional` are read only,
6266 * and should use this method.
6367 */
6468 private readOnlyExecute ( sql : string , params ?: any [ ] ) {
65- return this . readLock ( ctx => ctx . execute ( sql , params ) ) ;
69+ return this . baseDB . readLock ( ( ctx ) => ctx . execute ( sql , params ) ) ;
6670 }
6771
6872 /**
@@ -78,23 +82,23 @@ export class RNQSDBAdapter extends BaseObserver<DBAdapterListener> implements DB
7882 /**
7983 * Execute a read-only query and return results
8084 */
81- async getAll < T > ( sql : string , parameters ?: any [ ] ) : Promise < T [ ] > {
85+ getAll : async < T > ( sql : string , parameters ?: any [ ] ) : Promise < T [ ] > = > {
8286 const res = await tx . execute ( sql , parameters ) ;
8387 return res . rows ?. _array ?? [ ] ;
8488 } ,
8589
8690 /**
8791 * Execute a read-only query and return the first result, or null if the ResultSet is empty.
8892 */
89- async getOptional < T > ( sql : string , parameters ?: any [ ] ) : Promise < T | null > {
93+ getOptional : async < T > ( sql : string , parameters ?: any [ ] ) : Promise < T | null > = > {
9094 const res = await tx . execute ( sql , parameters ) ;
9195 return res . rows ?. item ( 0 ) ?? null ;
9296 } ,
9397
9498 /**
9599 * Execute a read-only query and return the first result, error if the ResultSet is empty.
96100 */
97- async get < T > ( sql : string , parameters ?: any [ ] ) : Promise < T > {
101+ get : async < T > ( sql : string , parameters ?: any [ ] ) : Promise < T > = > {
98102 const res = await tx . execute ( sql , parameters ) ;
99103 const first = res . rows ?. item ( 0 ) ;
100104 if ( ! first ) {
0 commit comments