A SurrealDB Query Builder written in Pure Dart.
❗ In order to start using Surrealdb Query Builder you must have the Dart SDK installed on your machine.
Add surrealdb_query_builder
to your pubspec.yaml
:
dependencies:
surrealdb_query_builder:
Install it:
dart pub get
-
SELECT
Statement -
LIVE SELECT
Statement -
CREATE
Statement -
USE
Statement -
INSERT
Statement -
UPDATE
Statement -
DELETE
Statement -
RELATE
Statement -
REMOVE
Statement
-
DEFINE
Statement
expect(
SurrealdbQueryBuilder.select(thing: 'person').build(),
equals('SELECT * FROM person;'),
);
expect(
SurrealdbQueryBuilder.select(thing: 'person')
.where()
.eq(field: 'name', value: 'Ayush')
.and()
.eq(field: 'age', value: '23')
.next()
.build(),
equals('SELECT * FROM person WHERE name = Ayush AND age = 23;'),
);
expect(
SurrealdbQueryBuilder.select(
thing: 'person',
omitfields: ['fullname'],
fields: ['name', 'age'],
)
.withIndex(indexes: ['unique_name'])
.where()
.eq(field: 'name', value: 'ayush')
.or()
.eq(field: 'name', value: 'ash')
.and()
.neq(field: 'age', value: '0')
.next()
.orderBy(orderBys: [
OrderBy(field: 'age', order: Order.desc, type: OrderType.numeric)
])
.limit(limit: '5')
.start(start: '0')
.fetch(fields: ['projects'])
.timeout(duration: '5s')
.parallel()
.build(),
equals(
'SELECT name, age OMIT fullname FROM person WITH INDEX unique_name '
'WHERE name = ayush OR name = ash AND age != 0 '
'ORDER age NUMERIC DESC LIMIT 5 START 0 '
'FETCH projects TIMEOUT 5s PARALLEL;'),
);
Surrealdb Query Builder comes with a built-in GitHub Actions workflow powered by Very Good Workflows but you can also add your preferred CI/CD solution.
Out of the box, on each pull request and push, the CI formats
, lints
, and tests
the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses Very Good Analysis for a strict set of analysis options used by our team. Code coverage is enforced using the Very Good Workflows.
To run all unit tests:
dart pub global activate coverage
dart pub global run coverage:test_with_coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info -b .
To view the generated coverage report you can use lcov.
# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
open coverage/index.html
Made with contrib.rocks.