dart_db 0.3.6 copy "dart_db: ^0.3.6" to clipboard
dart_db: ^0.3.6 copied to clipboard

Embedded database for Dart servers: tables from your own models, Diesel-style queries, joins and transactions (db_dsl) on Rust and LMDB 1.0, for Linux, macOS and Windows.

example/README.md

dart_db example #

server.dart is a small HTTP API on dart_db:

  • GET /notes?author=ada lists the notes of an author, through an index;
  • POST /notes with {"id": 1, "author": "ada", "text": "..."} stores one, and a duplicate id answers 409 from the ConstraintError of the insert.

The Note model is a plain class with fromJson and toJson that carries its table:

static final DbTable<Note> table = DbTable<Note>(
  'notes',
  key: 'id',
  fromJson: Note.fromJson,
  indexes: [Index(['author'])],
);

DartDb.open(path) lists no table: notes defines itself on its first use. The routes query Note.table.author.eq(name) through NoteFields, the extension the db_dsl_lints analyzer plugin writes from the model.

Run it, or compile it ahead of time with the native library bundled:

dart run example/server.dart
dart build cli -t example/server.dart -o build/server
./build/server/bundle/bin/server
1
likes
160
points
491
downloads

Documentation

API reference

Publisher

verified publisherjhonacode.com

Weekly Downloads

Embedded database for Dart servers: tables from your own models, Diesel-style queries, joins and transactions (db_dsl) on Rust and LMDB 1.0, for Linux, macOS and Windows.

Repository (GitHub)
View/report issues

Topics

#server #backend #database #lmdb #query-builder

License

MIT (license)

Dependencies

code_assets, db_dsl, ffi, hooks, result_controller

More

Packages that depend on dart_db