queryData method
Future<List>
queryData(
- String collectionId, {
- required Map<
String, dynamic> where, - required String orderBy,
- bool descending = true,
- int? limit,
- int? offset,
- List<
Object?> ? startAfter,
override
Implementation
@override
Future<List> queryData(
String collectionId, {
required Map<String, dynamic> where,
required String orderBy,
bool descending = true,
int? limit,
int? offset,
List<Object?>? startAfter, // 사용안됨.
}) async {
logger.finest('queryData $collectionId');
await initialize();
assert(AbsDatabase.sbDBConn != null);
if (AbsDatabase.sbDBConn == null) {
logger.severe('sbDBConn is null');
return [];
}
SupabaseQueryBuilder fromRef = AbsDatabase.sbDBConn!.from(collectionId);
PostgrestFilterBuilder filterBuilder = fromRef.select();
where.forEach((key, value) {
filterBuilder = queryMaker('"$key"', OperType.isEqualTo, value, filterBuilder);
});
// Map<String, Object> objWhere = {};
// where.forEach((key, value) {
// objWhere[key] = value;
// });
if (limit != null) {
if (offset != null) {
return await filterBuilder
.order(orderBy, ascending: !descending)
.limit(limit)
.range(offset, offset + limit);
}
return await filterBuilder.order(orderBy, ascending: !descending).limit(limit);
}
return await filterBuilder.order(orderBy, ascending: !descending);
}