cachapa / sqlite_crdt Goto Github PK
View Code? Open in Web Editor NEWDart implementation of Conflict-free Replicated Data Types (CRDTs) using Sqlite
Home Page: https://pub.dev/packages/sqlite_crdt
License: Apache License 2.0
Dart implementation of Conflict-free Replicated Data Types (CRDTs) using Sqlite
Home Page: https://pub.dev/packages/sqlite_crdt
License: Apache License 2.0
Originally posted by mochar February 15, 2024
The error is:
Unhandled exception:
type 'SelectInsertSource' is not a subtype of type 'ValuesSource' in type cast
#0 TimestampedCrdt._insert (package:sql_crdt/src/timestamped_crdt.dart:28:32)
#1 SqlCrdt._insert (package:sql_crdt/src/sql_crdt.dart:28:17)
#2 BaseCrdt.execute (package:sql_crdt/src/base_crdt.dart:48:13)
#3 main (file:///home/mochar/dev/garbage/crdt_insert_bug/main.dart:27:14)
<asynchronous suspension>
Minimal example:
import 'package:sqlite_crdt/sqlite_crdt.dart';
Future<void> onCreate(BaseCrdt crdt, int version) async {
await crdt.execute('''
CREATE TABLE test (
a INTEGER,
b INTEGER
)
''');
await crdt.execute('''
CREATE TABLE test2 (
a INTEGER,
b INTEGER
)
''');
}
void main() async {
final db = await SqliteCrdt.open('/tmp/a.sqlite',
version: 1,
onCreate: onCreate);
await db.execute('''
INSERT INTO test(a, b) VALUES (1, 2)
''');
await db.execute('''
INSERT INTO test2(a, b)
SELECT a, b
FROM test
''');
}
```</div>
I currently build and use the package pocketbase_drift which is a dart native client for pocketbase and uses drift as the Sqlite3 layer.
I ended up doing something very similar to a CRDT for the sync (deleted, timestamp, synced) which was possible with the added columns.
As I am looking into this package more I think that this might be a good fit. But would like to make a drift_crdt first or sqlite3_crdt client first. Sqlite3 being an FFI based package.
Curious about your thoughts on this in regards to pocketbase being the source of truth on the server running SQLite, having hooks and can be extended as a framework. Looking through the code I want to find a way to call getChangeSet for a user and only sync specific tables and ones only needed for the user. It wasnt clear to me if the crdt_sync was syncing the whole database to every peer or just the user data.
The applications I am working on are all offline first and have highly connected peers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.