surrealdb 0.6.0 copy "surrealdb: ^0.6.0" to clipboard
surrealdb: ^0.6.0 copied to clipboard

outdated

SurrealDB client written in pure dart. Auto reconnect, Typed functions

example/example.dart

import 'package:surrealdb/surrealdb.dart';

void main(List<String> args) async {
  final options = SurrealDBOptions(
    timeoutDuration: const Duration(seconds: 30),
  );

  var client = SurrealDB('ws://localhost:8000/rpc', options: options);

  client.connect();
  await client.wait();
  await client.use('test', 'test');
  await client.signin(user: 'root', pass: 'root');

  var person = await client.create('person', TestModel(false, 'Title'));

  var person2 = await client.create('person', {
    'title': 'Founder & CEO',
    'name': {
      'first': 'Tobie',
      'last': 'Morgan Hitchcock',
    },
    'marketing': false,
  });

  var persons = await client.select('person');

  var groupByQuery = await client.query(
    'SELECT marketing, count() FROM type::table(\$tb) GROUP BY marketing',
    {
      'tb': 'person',
    },
  );

  print(person);
  print(person2);
  print(persons);
  print(groupByQuery);
}

class TestModel {
  final bool marketing;
  final String title;

  TestModel(this.marketing, this.title);

  static fromJson(Map<String, dynamic> json) {
    return TestModel(json['marketing'], json['title']);
  }

  toJson() {
    return {
      'marketing': marketing,
      'title': title,
    };
  }
}
33
likes
0
pub points
66%
popularity

Publisher

verified publisherduhanbalci.com

SurrealDB client written in pure dart. Auto reconnect, Typed functions

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

web_socket_channel

More

Packages that depend on surrealdb