Skip to content

Commit b77b55a

Browse files
added comments
1 parent 1032954 commit b77b55a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/src/web/database.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,20 @@ class WebDatabase
4545
Future<void> get isInitialized => initialize();
4646

4747
@override
48+
49+
/// Not relevant for web.
4850
Never isolateConnectionFactory() {
4951
throw UnimplementedError();
5052
}
5153

5254
@override
55+
56+
/// Not supported on web. There is only 1 connection.
5357
int get maxReaders => throw UnimplementedError();
5458

5559
@override
60+
61+
/// Not relevant for web.
5662
Never get openFactory => throw UnimplementedError();
5763

5864
@override
@@ -209,6 +215,12 @@ class _ExclusiveTransactionContext extends _ExclusiveContext {
209215
@override
210216
Future<ResultSet> execute(String sql,
211217
[List<Object?> parameters = const []]) async {
218+
// Operations inside transactions are executed with custom requests
219+
// in order to verify that the connection does not have autocommit enabled.
220+
// The worker will check if autocommit = true before executing the SQL.
221+
// An exception will be thrown if autocommit is enabled.
222+
// The custom request which does the above will return the ResultSet as a formatted
223+
// JavaScript object. This is the converted into a Dart ResultSet.
212224
return await wrapSqliteException(() async {
213225
var res = await _database._database.customRequest(CustomDatabaseMessage(
214226
CustomDatabaseMessageKind.executeInTransaction, sql, parameters));

lib/src/web/worker/worker_utils.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import 'package:sqlite_async/sqlite3_common.dart';
88

99
import '../protocol.dart';
1010

11+
/// A base class for a web worker SQLite controller.
12+
/// This returns an instance of [AsyncSqliteDatabase] which
13+
/// can be extended to perform custom requests.
1114
base class AsyncSqliteController extends DatabaseController {
1215
@override
1316
Future<WorkerDatabase> openDatabase(
@@ -26,6 +29,8 @@ base class AsyncSqliteController extends DatabaseController {
2629
}
2730
}
2831

32+
/// Worker database which handles custom requests. These requests are used for
33+
/// handling exclusive locks for shared web workers and custom SQL execution scripts.
2934
class AsyncSqliteDatabase extends WorkerDatabase {
3035
@override
3136
final CommonDatabase database;

0 commit comments

Comments
 (0)