getById method
Future<T?>
getById(
- Id id
)
override
Implementation
@override
Future<T?> getById(Id id) async {
// Search across all scopes for the given id. This keeps the API simple,
// though most flows should use query(scope) for better performance.
final idStr = idToString(id);
final q = db.select(db.items)..where((t) => t.id.equals(idStr));
// Prefer non-deleted row if supportsSoftDelete
final rows = await q.get();
if (rows.isEmpty) return null;
// Filter soft-deleted if applicable
final active = supportsSoftDelete
? rows.where((r) => r.deletedAt == null).toList()
: rows;
final row = (active.isNotEmpty ? active.first : rows.first);
return fromJson(jsonDecode(row.payload) as Map<String, dynamic>);
}