File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,13 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection {
287287 return database.isolateConnectionFactory ();
288288 }
289289
290+ /// Get an unique id for this client.
291+ /// This id is only reset when the database is deleted.
292+ Future <String > getClientId () async {
293+ final row = await get ('SELECT powersync_client_id() as client_id' );
294+ return row['client_id' ] as String ;
295+ }
296+
290297 /// Get upload queue size estimate and count.
291298 Future <UploadQueueStats > getUploadQueueStats (
292299 {bool includeSize = false }) async {
Original file line number Diff line number Diff line change 11import 'package:sqlite_async/mutex.dart' ;
22import 'package:test/test.dart' ;
3+ import 'package:uuid/parsing.dart' ;
4+ import 'package:uuid/v4.dart' ;
35import 'utils/test_utils_impl.dart' ;
46
57final testUtils = TestUtils ();
@@ -79,5 +81,13 @@ void main() {
7981 await db.execute ('PRAGMA wal_checkpoint(TRUNCATE)' );
8082 await db.execute ('VACUUM' );
8183 });
84+
85+ test ('should have a client id' , () async {
86+ final db = await testUtils.setupPowerSync (path: path);
87+
88+ final id = await db.getClientId ();
89+ // Check that it is a valid uuid
90+ final _uuid = UuidParsing .parseAsByteList (id);
91+ });
8292 });
8393}
You can’t perform that action at this time.
0 commit comments