raindrop_sqlite 0.1.1 copy "raindrop_sqlite: ^0.1.1" to clipboard
raindrop_sqlite: ^0.1.1 copied to clipboard

The SQLite driver for raindrop, built on top of the sqlite3 package.

💧 raindrop_sqlite

Pub ci coverage style: very good analysis License: MIT


The SQLite driver for raindrop, built on sqlite3.

Usage #

Declare tables with sqliteTable, then hand a SQLiteDelegate to Raindrop:

import 'package:raindrop/raindrop.dart';
import 'package:raindrop_sqlite/raindrop_sqlite.dart';
import 'package:sqlite3/sqlite3.dart';

final users = sqliteTable('users', UserSchema.new);

void main() async {
  final db = Raindrop(SQLiteDelegate(sqlite3.openInMemory()));

  final [user] = await db.insert(into: users).values([
    const User(name: 'Alex'),
  ]).returning();
}

SQLite ships with foreign key enforcement off, so the delegate turns it on for its connection. Pass enforceForeignKeys: false to keep your own setting.

Beyond the core DSL #

Everything in the core raindrop DSL works unchanged. On top of it this driver adds upserts:

await db.insert(into: users).values([user])
    .onConflict([users.email])
    .doUpdate([users.age.to(excluded(users.age))]);
// INSERT ... ON CONFLICT ("email") DO UPDATE SET "age" = "excluded"."age"
  • insertOrIgnore renders INSERT OR IGNORE, skipping conflicting rows.
  • returning() on inserts, updates and deletes yields the affected rows.
  • .limit(n) caps updates and deletes. The driver probes the library for SQLITE_ENABLE_UPDATE_DELETE_LIMIT and falls back to a key-based rewrite.
  • unixepoch() and currentTimestamp() evaluate in the database.
  • Column types beyond the core set: boolean, dateTime (milliseconds since the epoch), bigInt and blob.
1
likes
160
points
175
downloads

Documentation

API reference

Publisher

verified publisherwolfenrain.dev

Weekly Downloads

The SQLite driver for raindrop, built on top of the sqlite3 package.

Repository (GitHub)
View/report issues
Contributing

Topics

#sql #database #sqlite #migrations

License

MIT (license)

Dependencies

raindrop, sqlite3

More

Packages that depend on raindrop_sqlite