rawGet<TModel extends SqliteModel> method

Future<List<TModel>> rawGet<TModel extends SqliteModel>(
  1. String sql,
  2. List arguments, {
  3. ModelRepository<SqliteModel>? repository,

Fetch results for model with a custom SQL statement. It is recommended to use get whenever possible. Advanced use only.


Future<List<TModel>> rawGet<TModel extends SqliteModel>(
  String sql,
  List arguments, {
  ModelRepository<SqliteModel>? repository,
}) async {
  final adapter = modelDictionary.adapterFor[TModel]!;

  final results = await _lock.synchronized(() async {
    return (await getDb()).rawQuery(sql, arguments);

  if (results.isEmpty || results.first.isEmpty) {
    // otherwise an empty sql result will generate a blank model
    return <TModel>[];

  return await Future.wait<TModel>(
      (row) => adapter.fromSqlite(row, provider: this, repository: repository) as Future<TModel>,