simpleQueryData method
Future<List>
simpleQueryData(
- String collectionId, {
- required String name,
- required String value,
- required String orderBy,
- bool descending = true,
- int? limit,
- int? offset,
override
Implementation
@override
Future<List> simpleQueryData(String collectionId,
{required String name,
required String value,
required String orderBy,
bool descending = true,
int? limit,
int? offset}) async {
await initialize();
try {
//String orderType = descending ? 'DESC' : 'ASC';
final result = await database!.listDocuments(
databaseId: myConfig!.serverConfig.dbConnInfo.appId,
collectionId: collectionId,
queries: [
Query.equal(name, value),
descending ? Query.orderDesc(orderBy) : Query.orderAsc(orderBy)
], // index 를 만들어줘야 함.
//orderAttributes: [orderBy],
//orderTypes: [orderType],
);
return result.documents.map((element) {
return element.data;
}).toList();
} on AppwriteException catch (e) {
if (e.code == 404) {
logger.finest(e.message!);
return [];
}
if (e.message != null) {
throw HycopException(message: e.message!, code: e.code);
}
throw HycopException(message: 'Appwrite error', code: e.code);
}
}