feat: inline storage columns in remote and local tables

This commit is contained in:
shenlong-tanwen
2025-07-11 01:37:02 +05:30
parent c482bdfae7
commit 023d2195f9
14 changed files with 444 additions and 119 deletions
@@ -9,23 +9,10 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
const DriftLocalAssetRepository(this._db) : super(_db);
Stream<LocalAsset?> watchAsset(String id) {
final query = _db.localAssetEntity
.select()
.addColumns([_db.localAssetEntity.id]).join([
leftOuterJoin(
_db.remoteAssetEntity,
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
useColumns: false,
),
])
..where(_db.localAssetEntity.id.equals(id));
final query = _db.localAssetEntity.select()
..where((row) => row.id.equals(id));
return query.map((row) {
final asset = row.readTable(_db.localAssetEntity).toDto();
return asset.copyWith(
remoteId: row.read(_db.remoteAssetEntity.id),
);
}).watchSingleOrNull();
return query.map((row) => row.toDto()).watchSingleOrNull();
}
Future<void> updateHashes(Iterable<LocalAsset> hashes) {