@@ -28,14 +28,14 @@ public class BasePowerSyncDatabaseOptions()
28
28
29
29
}
30
30
31
- public abstract class DatabaseSource { }
31
+ public interface IDatabaseSource { }
32
32
33
- public class DBAdapterSource ( IDBAdapter Adapter ) : DatabaseSource
33
+ public class DBAdapterSource ( IDBAdapter Adapter ) : IDatabaseSource
34
34
{
35
35
public IDBAdapter Adapter { get ; init ; } = Adapter ;
36
36
}
37
37
38
- public class OpenFactorySource ( ISQLOpenFactory Factory ) : DatabaseSource
38
+ public class OpenFactorySource ( ISQLOpenFactory Factory ) : IDatabaseSource
39
39
{
40
40
public ISQLOpenFactory Factory { get ; init ; } = Factory ;
41
41
}
@@ -45,8 +45,7 @@ public class PowerSyncDatabaseOptions() : BasePowerSyncDatabaseOptions()
45
45
/// <summary>
46
46
/// Source for a SQLite database connection.
47
47
/// </summary>
48
- public DatabaseSource Database { get ; set ; } = null ! ;
49
-
48
+ public IDatabaseSource Database { get ; set ; } = null ! ;
50
49
}
51
50
52
51
public class PowerSyncDBEvent : StreamingSyncImplementationEvent
@@ -63,6 +62,25 @@ public interface IPowerSyncDatabase : IEventStream<PowerSyncDBEvent>
63
62
public Task < CrudBatch ? > GetCrudBatch ( int limit ) ;
64
63
65
64
public Task < CrudTransaction ? > GetNextCrudTransaction ( ) ;
65
+
66
+ Task < NonQueryResult > Execute ( string query , object [ ] ? parameters = null ) ;
67
+
68
+ Task < T [ ] > GetAll < T > ( string sql , params object [ ] ? parameters ) ;
69
+
70
+ Task < T ? > GetOptional < T > ( string sql , params object [ ] ? parameters ) ;
71
+
72
+ Task < T > Get < T > ( string sql , params object [ ] ? parameters ) ;
73
+
74
+ Task < T > ReadLock < T > ( Func < ILockContext , Task < T > > fn , DBLockOptions ? options = null ) ;
75
+
76
+ Task < T > ReadTransaction < T > ( Func < ITransaction , Task < T > > fn , DBLockOptions ? options = null ) ;
77
+
78
+ Task WriteLock ( Func < ILockContext , Task > fn , DBLockOptions ? options = null ) ;
79
+ Task < T > WriteLock < T > ( Func < ILockContext , Task < T > > fn , DBLockOptions ? options = null ) ;
80
+
81
+ Task WriteTransaction ( Func < ITransaction , Task > fn , DBLockOptions ? options = null ) ;
82
+ Task < T > WriteTransaction < T > ( Func < ITransaction , Task < T > > fn , DBLockOptions ? options = null ) ;
83
+
66
84
}
67
85
68
86
public class PowerSyncDatabase : EventStream < PowerSyncDBEvent > , IPowerSyncDatabase
@@ -102,9 +120,6 @@ public PowerSyncDatabase(PowerSyncDatabaseOptions options)
102
120
}
103
121
else if ( options . Database is SQLOpenOptions openOptions )
104
122
{
105
- // TODO default to MDSQLite factory for now
106
- // Can be broken out, rename this class to Abstract
107
- // `this.openDBAdapter(options)`
108
123
Database = new MDSQLiteAdapter ( new MDSQLiteAdapterOptions
109
124
{
110
125
Name = openOptions . DbFilename ,
@@ -346,7 +361,6 @@ public async Task DisconnectAndClear()
346
361
await Disconnect ( ) ;
347
362
await WaitForReady ( ) ;
348
363
349
- // TODO CL bool clearLocal = options?.ClearLocal ?? false;
350
364
bool clearLocal = true ;
351
365
352
366
await Database . WriteTransaction ( async tx =>
@@ -364,12 +378,6 @@ await Database.WriteTransaction(async tx =>
364
378
base . Close ( ) ;
365
379
await WaitForReady ( ) ;
366
380
367
- // TODO CL
368
- // if (options.Disconnect)
369
- // {
370
- // await Disconnect();
371
- // }
372
-
373
381
syncStreamImplementation ? . Close ( ) ;
374
382
BucketStorageAdapter ? . Close ( ) ;
375
383
0 commit comments