queryMap method
Future<List<Map<String, dynamic> > >
queryMap({
- Filter where(
- TMeta t
- Iterable<
ColumnDefinition< ? columns(IEntity, dynamic> >- TMeta t
- List<
OrmOrder> ? orderBy(- TMeta t
- int? limit,
- int? offset,
- bool? useIsolate,
- Map<
String, dynamic> ? isolateArgs, - void onIsolatePreMap()?,
inherited
Implementation
@override
@protected
Future<List<Map<String, dynamic>>> queryMap({
Filter Function(TMeta t)? where,
Iterable<ColumnDefinition>? Function(TMeta t)? columns,
List<OrmOrder>? Function(TMeta t)? orderBy,
int? limit,
int? offset,
final bool? useIsolate,
Map<String, dynamic>? isolateArgs,
void Function(Map<String, dynamic>? isolateArgs)? onIsolatePreMap,
}) async {
List<Map<String, dynamic>> maps;
final db = await dbContext.database;
final cols1 = columns?.call(t);
if (cols1 == null) {
throw ArgumentError('no columns supplied');
}
List<String> cols = [];
for (var element in cols1) {
cols.add(element.name);
}
if (cols.isEmpty) {
throw ArgumentError('no columns supplied');
}
String? orderByFilter = orderBy
?.call(t)
?.map((e) =>
'${e.column.name} ${e.direction == OrderDirection.desc ? ' DESC' : ''}')
.join(',');
if (where == null) {
maps = await db.query(
t.tableName,
columns: cols,
orderBy: orderByFilter,
limit: limit,
offset: offset,
);
} else {
final formattedQuery = await whereString(where, useIsolate);
maps = await db.query(
t.tableName,
columns: cols,
where: formattedQuery.filter,
whereArgs: formattedQuery.whereArgs,
orderBy: orderByFilter,
limit: limit,
offset: offset,
);
}
return maps;
}