get<T> method

Future<T?> get<T>(
  1. Object tableEntityInstance,
  2. String afterWhere, [
  3. List<Object?>? whereArgs
])

Returns a single entity of type T matching the afterWhere clause, or null when no row matches. ? placeholders in afterWhere take their values from whereArgs.

Throws DatabaseException if the entity table does not exist.

Implementation

Future<T?> get<T>(
  Object tableEntityInstance,
  String afterWhere, [
  List<Object?>? whereArgs,
]) async {
  final List<Map<String, Object?>> rows = await _selectWhere(
    '*',
    quoteIdentifier(_tableFor<T>()),
    afterWhere,
    whereArgs,
  );
  if (rows.isEmpty) return null;
  return (tableEntityInstance as dynamic).fromMap(rows.first) as T;
}