@@ -57,7 +57,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
5757 }
5858
5959 protected async init ( ) {
60- const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous, encryptionKey } = this . options . sqliteOptions ;
60+ const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous } = this . options . sqliteOptions ! ;
6161 const dbFilename = this . options . name ;
6262
6363 this . writeConnection = await this . openConnection ( dbFilename ) ;
@@ -99,7 +99,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
9999
100100 protected async openConnection ( filenameOverride ?: string ) : Promise < OPSQLiteConnection > {
101101 const dbFilename = filenameOverride ?? this . options . name ;
102- const DB : DB = this . openDatabase ( dbFilename , this . options . sqliteOptions . encryptionKey ) ;
102+ const DB : DB = this . openDatabase ( dbFilename , this . options . sqliteOptions ? .encryptionKey ?? undefined ) ;
103103
104104 //Load extensions for all connections
105105 this . loadAdditionalExtensions ( DB ) ;
@@ -139,7 +139,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
139139 }
140140
141141 private loadAdditionalExtensions ( DB : DB ) {
142- if ( this . options . sqliteOptions . extensions . length > 0 ) {
142+ if ( this . options . sqliteOptions ?. extensions && this . options . sqliteOptions . extensions . length > 0 ) {
143143 for ( const extension of this . options . sqliteOptions . extensions ) {
144144 DB . loadExtension ( extension . path , extension . entryPoint ) ;
145145 }
@@ -292,8 +292,10 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
292292 await this . initialized ;
293293 await this . writeConnection ! . refreshSchema ( ) ;
294294
295- for ( let readConnection of this . readConnections ) {
296- await readConnection . connection . refreshSchema ( ) ;
295+ if ( this . readConnections ) {
296+ for ( let readConnection of this . readConnections ) {
297+ await readConnection . connection . refreshSchema ( ) ;
298+ }
297299 }
298300 }
299301}
0 commit comments