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 {
287
287
return database.isolateConnectionFactory ();
288
288
}
289
289
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
+
290
297
/// Get upload queue size estimate and count.
291
298
Future <UploadQueueStats > getUploadQueueStats (
292
299
{bool includeSize = false }) async {
Original file line number Diff line number Diff line change 1
1
import 'package:sqlite_async/mutex.dart' ;
2
2
import 'package:test/test.dart' ;
3
+ import 'package:uuid/parsing.dart' ;
4
+ import 'package:uuid/v4.dart' ;
3
5
import 'utils/test_utils_impl.dart' ;
4
6
5
7
final testUtils = TestUtils ();
@@ -79,5 +81,13 @@ void main() {
79
81
await db.execute ('PRAGMA wal_checkpoint(TRUNCATE)' );
80
82
await db.execute ('VACUUM' );
81
83
});
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
+ });
82
92
});
83
93
}
You can’t perform that action at this time.
0 commit comments