getData method

  1. @override
Future<Map<String, dynamic>> getData(
  1. String collectionId,
  2. String mid
)
override

Implementation

@override
Future<Map<String, dynamic>> getData(String collectionId, String mid) async {
  // List resultList =
  //     await simpleQueryData(collectionId, name: 'mid', value: mid, orderBy: 'updateTime');
  // return resultList.first;
  await initialize();
  String key = HycopUtils.midToKey(mid);
  try {
    final doc = await database!.getDocument(
      databaseId: myConfig!.serverConfig.dbConnInfo.appId,
      collectionId: collectionId,
      documentId: key,
    );
    return doc.data;
  } 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);
  }
}