surrealdb 0.4.4 surrealdb: ^0.4.4 copied to clipboard
SurrealDB client written in pure dart. auto reconnect, typed functions
SurrealDB Client For Dart & Flutter #
SurrealDB client for Dart and Flutter.
Quick Start #
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('root', 'root');
var person = await client.create('person', {
'title': 'Founder & CEO',
'name': {
'first': 'Tobie',
'last': 'Morgan Hitchcock',
},
'marketing': false,
});
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',
},
);
}
Features #
connect()
#
Connects to a database endpoint provided in constructer and authenticate with token if provided in constructer.
close()
#
Closes the persistent connection to the database.
wait()
#
Ensures connections established with the database and pinged successfully.
ping()
#
Closes the persistent connection to the database.
use(String namespace, String database)
#
Switch to a specific namespace and database.
info()
#
Retrieve info about the current Surreal instance
signup(String user, String pass)
#
Signs up to a specific authentication scope
signin(String user, String pass)
#
Signs in to a specific authentication scope
invalidate()
#
Invalidates the authentication for the current connection
authenticate(String token)
#
Authenticates the current connection with a JWT token
kill(String query)
#
Kill a specific query
let(String key, String val)
#
Assigns a value as a parameter for this connection
create(String thing, dynamic data)
#
Creates a record in the database. data
has to be json encodable object or class
has toJson
method.
Future<List<T>> select(String table)
#
Selects all records in a table, or a specific record, from the database
query(String query, [Map<String, Object?>? vars])
#
Runs a set of SurrealQL statements against the database
update(String thing, [Object? data])
#
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.
change(String thing, [Object? 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.
modify(String thing, [Object? 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.
delete(String thing)
#
Deletes all records in a table, or a specific record, from the database