File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
packages/powersync-op-sqlite/src/db Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,9 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
8888 const dbFilename = filenameOverride ?? this . options . name ;
8989 const DB : DB = this . openDatabase ( dbFilename , this . options . sqliteOptions . encryptionKey ) ;
9090
91- //Load extension for all connections
92- this . loadExtension ( DB ) ;
91+ //Load extensions for all connections
92+ this . loadAdditionalExtensions ( DB ) ;
93+ this . loadPowerSyncExtension ( DB ) ;
9394
9495 await DB . execute ( 'SELECT powersync_init()' ) ;
9596
@@ -124,7 +125,15 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
124125 }
125126 }
126127
127- private loadExtension ( DB : DB ) {
128+ private loadAdditionalExtensions ( DB : DB ) {
129+ if ( this . options . sqliteOptions . extensions . length > 0 ) {
130+ for ( const extension of this . options . sqliteOptions . extensions ) {
131+ DB . loadExtension ( extension . path , extension . entryPoint ) ;
132+ }
133+ }
134+ }
135+
136+ private loadPowerSyncExtension ( DB : DB ) {
128137 if ( Platform . OS === 'ios' ) {
129138 const bundlePath : string = NativeModules . PowerSyncOpSqlite . getBundlePath ( ) ;
130139 const libPath = `${ bundlePath } /Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core` ;
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ export interface SqliteOptions {
2929 * If set, the database will be encrypted using SQLCipher.
3030 */
3131 encryptionKey ?: string ;
32+
33+ /**
34+ * Load extensions using the path and entryPoint.
35+ * More info can be found here https://op-engineering.github.io/op-sqlite/docs/api#loading-extensions.
36+ */
37+ extensions ?: Array < {
38+ path : string ;
39+ entryPoint ?: string ;
40+ } > ;
3241}
3342
3443// SQLite journal mode. Set on the primary connection.
@@ -57,5 +66,6 @@ export const DEFAULT_SQLITE_OPTIONS: Required<SqliteOptions> = {
5766 synchronous : SqliteSynchronous . normal ,
5867 journalSizeLimit : 6 * 1024 * 1024 ,
5968 lockTimeoutMs : 30000 ,
60- encryptionKey : null
69+ encryptionKey : null ,
70+ extensions : [ ]
6171} ;
You can’t perform that action at this time.
0 commit comments