setData method

  1. @override
Future<void> setData(
  1. String collectionId,
  2. String mid,
  3. Object data
)
override

Implementation

@override
Future<void> setData(String collectionId, String mid, Object data) async {
  await initialize();

  try {
    String key = HycopUtils.midToKey(mid);
    logger.finest('setData($key)');
    await database!.updateDocument(
      databaseId: myConfig!.serverConfig.dbConnInfo.appId,
      collectionId: collectionId,
      documentId: key,
      data: data as Map<String, dynamic>,
    );
  } 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);
  }
}