Skip to content

Commit

Permalink
chore: build surrealdb.wasm 0.9.0 for surrealdb 1.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
limcheekin committed Mar 13, 2024
1 parent b692187 commit c00da47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-wasm-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:

- name: "Checkout surrealdb.wasm repo (latest tag)"
run: |
git clone https://github.com/limcheekin/surrealdb.wasm.git
#cd surrealdb.wasm;export LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
#git checkout $LATEST_TAG
git clone https://github.com/surrealdb/surrealdb.wasm.git
cd surrealdb.wasm;export LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
git checkout $LATEST_TAG
- name: "Install Node & NPM"
uses: actions/setup-node@v4
Expand Down
8 changes: 4 additions & 4 deletions integration_test/surrealdb_wasm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ DEFINE FIELD created ON document TYPE datetime;
};
final created = await db.create('person', data);
final tom = Map<String, dynamic>.from(created! as Map);
final results = (await db.select(tom['id'] as String))! as List;
final selectedTom = Map<String, dynamic>.from(results.first as Map);
final result = await db.select(tom['id'] as String);
final selectedTom = Map<String, dynamic>.from(result! as Map);
expect(tom['name'], equals(selectedTom['name']));
});

Expand Down Expand Up @@ -173,8 +173,8 @@ DEFINE FIELD created ON document TYPE datetime;
final tom = Map<String, dynamic>.from(created! as Map);
final id = tom['id'] as String;
await db.delete(id);
final results = (await db.select('person'))! as List;
expect(results, isEmpty);
final result = await db.select('person');
expect(result, isNull);
});

testWidgets('set test', (WidgetTester tester) async {
Expand Down
9 changes: 7 additions & 2 deletions lib/src/surrealdb_wasm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,16 @@ class Surreal {
/// final person = await db.select('person:h5wxrf2ewk8xjxosxtyc');
/// ```
Future<Object?> select(String resource) async {
print('** select resource $resource');
final result = await promiseToFuture<Object?>(
_surreal.select(
resource,
),
);
return dartify(result)! as List;
print('** select result $result');
final list = dartify(result)! as List;
print('** select list $list');
return list.isEmpty ? null : (list.length == 1 ? list.first : list);
}

/// Executes a SurrealQL query on the database.
Expand Down Expand Up @@ -419,7 +423,8 @@ class Surreal {
resource,
),
);
return dartify(result);
final list = dartify(result)! as List;
return list.isEmpty ? null : (list.length == 1 ? list.first : list);
}

/// Executes a transaction by calling the provided [action] function
Expand Down

0 comments on commit c00da47

Please sign in to comment.