surrealdb_client 0.1.0
surrealdb_client: ^0.1.0 copied to clipboard
Experimental Dart support for SurrealDB - database, realtime API layer, and security permissions all-in-one.
Experimental Dart support for SurrealDB. This package is a port of surreal.js.
Features #
connect(url)- Connects to a local or remote database endpointwait()- Waits for the connection to the database to succeedclose()- Closes the persistent connection to the databaseuse(ns, db)- Switch to a specific namespace and databasesignup(vars)- Signs this connection up to a specific authentication scopesignin(vars)- Signs this connection in to a specific authentication scopeinvalidate()- Invalidates the authentication for the current connectionauthenticate(token)- Authenticates the current connection with a JWT tokenlet(key, val)- Assigns a value as a parameter for this connectionquery(sql, vars)- Runs a set of SurrealQL statements against the databaseselect(thing)- Selects all records in a table, or a specific recordcreate(thing, data)- Creates a record in the databaseupdate(thing, data)- Updates all records in a table, or a specific recordchange(thing, data)- Modifies all records in a table, or a specific recordmodify(thing, data)- Applies JSON Patch changes to all records in a table, or a specific recorddelete(thing)- Deletes all records, or a specific record
Getting started #
For installation instructions and SurrealQL introduction visit SurrealDB docs.
Usage #
// Tell the client where to find your Surreal instance on the network.
final client = SurrealClient(url: '...');
// Sign in and specify which namespace and database client should be referring to.
await client.signIn({'user': 'root', 'pass': 'root'});
await client.use('test', 'test');
// Create and read an article.
await client.create('article', {'title': 'SurrealDB for Dart'});
print(await client.select('article'));
// Close the connection.
client.close();
Additional information #
This is a 3rd-party integration which happens to also be an experimental one. Keep that in mind when considering this package as a foundation of your project.
Contributions are welcome.
Planned improvements:
- ✅ Add web support
- ❌ Add types to outputs
- ❌ Provide streams for client events