surrealdb_query_builder 0.4.0 copy "surrealdb_query_builder: ^0.4.0" to clipboard
surrealdb_query_builder: ^0.4.0 copied to clipboard

A SurrealDB Query Builder written in Pure Dart

Surrealdb Query Builder #

pub package ci style: very good analysis License: MIT

A SurrealDB Query Builder written in Pure Dart.

Installation ๐Ÿ’ป #

โ— 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

Features โœจ #

  • โœ… SELECT Statement
  • โœ… LIVE SELECT Statement
  • โœ… CREATE Statement
  • โœ… USE Statement
  • โŒ INSERT Statement
  • โŒ UPDATE Statement
  • โŒ DELETE Statement
  • โŒ RELATE Statement
  • โŒ REMOVE Statement

Maybe #

  • โŒ DEFINE Statement

Examples #


  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;'),
  );

Continuous Integration ๐Ÿค– #

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.


Running Tests ๐Ÿงช #

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

Contributors ๐Ÿ’ช #

contributors

Made with contrib.rocks.

3
likes
130
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A SurrealDB Query Builder written in Pure Dart

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on surrealdb_query_builder