实验性 Dart 支持 SurrealDB。此包是 surreal.js 的移植版。
特点
connect(url)– 连接到本地或远程数据库端点wait()– 等待数据库连接成功close()– 关闭到数据库的持久连接use(ns, db)– 切换到特定的命名空间和数据库signup(vars)– 将此连接注册到特定的认证范围signin(vars)– 将此连接登录到特定的认证范围invalidate()– 使当前连接的认证无效authenticate(token)– 使用 JWT 令牌对当前连接进行认证let(key, val)– 将值作为参数分配给此连接query(sql, vars)– 对数据库运行一组 SurrealQL 语句select(thing)– 选择表中的所有记录,或特定记录create(thing, data)– 在数据库中创建记录update(thing, data)– 更新表中的所有记录,或特定记录change(thing, data)– 修改表中的所有记录,或特定记录modify(thing, data)– 将 JSON Patch 更改应用于表中的所有记录,或特定记录delete(thing)– 删除所有记录,或特定记录
入门
有关安装说明和 SurrealQL 简介,请访问 SurrealDB 文档。
用法
// 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();
附加信息
这是第三方集成,也是一个实验性集成。在考虑将此包作为项目基础时,请牢记这一点。
欢迎贡献。
计划改进
- 添加 Web 支持
- 为输出添加类型
- 为客户端事件提供流