SurrealDB client for Dart and Flutter.
import 'package:surrealdb/surrealdb.dart';
void main(List<String> args) async {
final client = SurrealDB('ws://localhost:8000/rpc');
client.connect();
await client.wait();
await client.use('test', 'test');
await client.signin(user: 'root', pass: 'root');
await client.create('person', TestModel(false, 'title'));
var person = await client.create('person', {
'title': 'Founder & CEO',
'name': {
'first': 'Tobie',
'last': 'Morgan Hitchcock',
},
'marketing': false,
});
print(person);
List<Map<String, Object?>> persons = await client.select('person');
final groupBy = await client.query(
'SELECT marketing, count() FROM type::table(\$tb) GROUP BY marketing',
{
'tb': 'person',
},
);
print(groupBy);
print(persons.length);
}
Connects to a database endpoint provided in constructer and authenticate with token if provided in constructer.
Closes the persistent connection to the database.
Ensures connections established with the database and pinged successfully.
Closes the persistent connection to the database.
Switch to a specific namespace and database.
Retrieve info about the current Surreal instance
Signs up to a specific authentication scope
Signs in to a specific authentication scope
Invalidates the authentication for the current connection
Authenticates the current connection with a JWT token
Kill a specific query
Assigns a value as a parameter for this connection
Creates a record in the database. data
has to be json encodable object or class
has toJson
method.
Selects all records in a table, or a specific record, from the database
Runs a set of SurrealQL statements against the database
Updates all records in a table, or a specific record, in the database NOTE: This function replaces the current document / record data with the specified data.
Modifies all records in a table, or a specific record, in the database NOTE: This function merges the current document / record data with the specified data.
Applies JSON Patch changes to all records, or a specific record, in the database NOTE: This function patches the current document / record data with the specified JSON Patch data.
Deletes all records in a table, or a specific record, from the database