read method

Future<SessionData?> read(
  1. UserId id
)

Returns the SessionData stored in the database by the provided id, if any.

Implementation

Future<SessionData?> read(UserId id) async {
  final SessionData? existing = data[id];
  if (existing != null) {
    return existing;
  }

  return await safe<SessionData?>((db) async {
    final stmt = db.select(db.versions)
      ..where((u) => u.userId.equals(id.val));
    final VersionRow? row = await stmt.getSingleOrNull();

    if (row == null) {
      return null;
    }

    return _SessionDataDb.fromDb(row);
  }, exclusive: false);
}