read method
- UserId id
Returns the DtoMyUser stored in the database by the provided id
, if
any.
Implementation
Future<DtoMyUser?> read(UserId id) async {
final DtoMyUser? existing = _cache[id];
if (existing != null) {
return existing;
}
return await safe<DtoMyUser?>(
(db) async {
final stmt = db.select(db.myUsers)..where((u) => u.id.equals(id.val));
final MyUserRow? row = await stmt.getSingleOrNull();
if (row == null) {
return null;
}
return _MyUserDb.fromDb(row);
},
tag: 'my_user.read($id)',
exclusive: false,
);
}