New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drift Example #60
base: master
Are you sure you want to change the base?
Drift Example #60
Conversation
You can make drift work with concurrency via WAL mode: Native...
return NativeDatabase.createInBackground(
file,
logStatements: logStatements,
cachePreparedStatements: true,
setup: (db) {
db.execute('PRAGMA journal_mode=WAL');
db.execute('PRAGMA busy_timeout=100');
},
);
... Web (WASM)...
final result = await WasmDatabase.open(
databaseName: dbName.replaceAll('.db', ''),
sqlite3Uri: sqliteUrl,
driftWorkerUri: Uri.parse('/drift_worker.js'),
initializeDatabase: preload,
localSetup: (db) {
db.execute('PRAGMA journal_mode=WAL');
db.execute('PRAGMA busy_timeout=100');
},
);
... |
In this case the database is managed by sqlite_async, which already uses WAL mode. The problem is with write we interact with Drift, we need write locks even for select statements (implicit in Also FWIW, no current VFS supports |
Now published as https://github.com/powersync-ja/drift_sqlite_async |
POC of using Drift as an ORM for the supabase-todolist demo.
The bulk of the integration is in thedrift_sqlite_async.dart
file, loosely based on the drift_sqflite query executor. The implementation applies to sqlite_async in general - nothing is directly coupled to PowerSync.Update: Uses the new drift_sqlite_async package.
Tested and working: