Skip to content

Commit

Permalink
fix exists
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Jul 10, 2024
1 parent 395fa07 commit e2bbede
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions app_cv_sembast/lib/src/db_record.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ class CvRecordRef<K, V extends DbRecord<K>> {
(await rawRef.put(db, value.toMap(), merge: merge)).cv<V>();

/// Check if exists.
Future<void> exists(DatabaseClient client) async {
await rawRef.exists(client);
}
Future<bool> exists(DatabaseClient client) => rawRef.exists(client);

/// Check if exists synchronously.
bool existsSync(DatabaseClient client) => rawRef.existsSync(client);
Expand Down
4 changes: 2 additions & 2 deletions app_cv_sembast/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: tekartik_app_cv_sembast
description: Sembast content values helper
version: 0.5.9
version: 1.0.0
publish_to: none
environment:
sdk: '>=3.3.0 <4.0.0'
sdk: '>=3.4.0 <4.0.0'

dependencies:
meta:
Expand Down
5 changes: 5 additions & 0 deletions app_cv_sembast/test/app_cv_sembast_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void main() {
var cvRecordRef = cvStore.record('1');
await store.record('1').put(db, {'value': 1});
expect(await recordRef.get(db), {'value': 1});
expect(await recordRef.exists(db), true);
var readDbTest = await cvRecordRef.get(db);
expect(readDbTest, dbTest);
expect(readDbTest!.rawRef.key, '1');
Expand Down Expand Up @@ -140,7 +141,11 @@ void main() {
var cvStore = cvStringRecordFactory.store<DbStringTest>('test');
var record = DbStringTest()..value.v = 1;
var docRef = cvStore.record('test');
expect(await docRef.exists(db), isFalse);
expect(await docRef.existsSync(db), isFalse);
await docRef.put(db, record);
expect(await docRef.exists(db), isTrue);
expect(await docRef.existsSync(db), isTrue);
var doc = docRef.cv();
expect(await docRef.get(db), record);
doc.value.v = 2;
Expand Down

0 comments on commit e2bbede

Please sign in to comment.