dart_node_better_sqlite3 0.11.0-beta copy "dart_node_better_sqlite3: ^0.11.0-beta" to clipboard
dart_node_better_sqlite3: ^0.11.0-beta copied to clipboard

Platformweb

Typed Dart bindings for better-sqlite3 npm package

dart_node_better_sqlite3 #

Typed Dart bindings for better-sqlite3. Synchronous SQLite3 with WAL mode.

Getting Started #

import 'package:dart_node_better_sqlite3/dart_node_better_sqlite3.dart';
import 'package:nadz/nadz.dart';

void main() {
  final db = switch (openDatabase('./my.db')) {
    Success(:final value) => value,
    Error(:final error) => throw Exception(error),
  };

  db.exec('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)');

  final stmt = switch (db.prepare('INSERT INTO users (name) VALUES (?)')) {
    Success(:final value) => value,
    Error(:final error) => throw Exception(error),
  };

  stmt.run(['Alice']);

  final query = switch (db.prepare('SELECT * FROM users')) {
    Success(:final value) => value,
    Error(:final error) => throw Exception(error),
  };

  final rows = query.all([]);
  print(rows);

  db.close();
}

Run #

npm install better-sqlite3
dart compile js -o app.js lib/main.dart
node app.js

Part of dart_node #

GitHub

0
likes
130
points
153
downloads

Publisher

verified publisherchristianfindlay.com

Weekly Downloads

Typed Dart bindings for better-sqlite3 npm package

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

austerity, dart_node_core, nadz

More

Packages that depend on dart_node_better_sqlite3