mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
readme
This commit is contained in:
parent
2eb301f62a
commit
c44268f9fa
2 changed files with 72 additions and 8 deletions
18
bindings/dart/DEVELOPMENT.md
Normal file
18
bindings/dart/DEVELOPMENT.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Development
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
- [Flutter](https://docs.flutter.dev/get-started/install)
|
||||
- [Rust](https://www.rust-lang.org/tools/install)
|
||||
- [frb](https://cjycode.com/flutter_rust_bridge/quickstart)
|
||||
|
||||
## Steps
|
||||
|
||||
- Modify rust code under `rust` directory;
|
||||
- Inside this directory, run `flutter_rust_bridge_codegen generate`
|
||||
- Modify dart code under `lib` directory;
|
||||
|
||||
## Run test
|
||||
|
||||
- From this directory, run `cargo build --package turso_dart --target-dir=rust/test_build`
|
||||
- Run `flutter test`
|
|
@ -2,14 +2,60 @@
|
|||
|
||||
Dart/Flutter binding for turso database.
|
||||
|
||||
## Pre-requisites
|
||||
## Getting Started
|
||||
|
||||
- [Flutter](https://docs.flutter.dev/get-started/install)
|
||||
- [Rust](https://www.rust-lang.org/tools/install)
|
||||
- [frb](https://cjycode.com/flutter_rust_bridge/quickstart)
|
||||
### Add it to your `pubspec.yaml`.
|
||||
|
||||
## Development
|
||||
```
|
||||
turso_dart:
|
||||
```
|
||||
|
||||
- Modify rust code under `rust` directory;
|
||||
- Inside this directory, run `flutter_rust_bridge_codegen generate`
|
||||
- Modify dart code under `lib` directory;
|
||||
### Create the client
|
||||
|
||||
- In memory
|
||||
|
||||
```dart
|
||||
final client = TursoClient.memory();
|
||||
```
|
||||
|
||||
- Local
|
||||
|
||||
```dart
|
||||
final dir = await getApplicationCacheDirectory();
|
||||
final path = '${dir.path}/local.db';
|
||||
final client = TursoClient.local(path);
|
||||
```
|
||||
|
||||
### Connect
|
||||
|
||||
```dart
|
||||
await client.connect();
|
||||
```
|
||||
|
||||
### Run SQL statements
|
||||
|
||||
- Create table
|
||||
|
||||
```dart
|
||||
await client.execute("create table if not exists customers (id integer primary key, name text);");
|
||||
```
|
||||
|
||||
- Insert query
|
||||
|
||||
```dart
|
||||
await client.query("insert into customers(name) values ('John Doe')");
|
||||
```
|
||||
|
||||
- Select query
|
||||
|
||||
```dart
|
||||
print(await client.query("select * from customers"));
|
||||
```
|
||||
|
||||
- Prepared statement
|
||||
|
||||
```dart
|
||||
final statement = await client
|
||||
.prepare("select * from customers where id = ?");
|
||||
await statement.query(positional: [1])
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue