getListFromDB method

Future<List<AbsExModel>> getListFromDB(
  1. String userId
)

Implementation

Future<List<AbsExModel>> getListFromDB(String userId) async {
  modelList.clear();
  try {
    Map<String, dynamic> query = {};
    query['creator'] = userId;
    query['isRemoved'] = false;
    List resultList = await HycopFactory.dataBase!.queryData(
      collectionId,
      where: query,
      orderBy: 'updateTime',
      //limit: 2,
      //offset: 1, // appwrite only
      //startAfter: [DateTime.parse('2022-08-04 12:00:01.000')], //firebase only
    );
    if (resultList.isEmpty) return [];
    return resultList.map((ele) {
      AbsExModel model = newModel(ele['mid'] ?? '');
      model.fromMap(ele);
      modelList.add(model);
      return model;
    }).toList();
  } catch (e) {
    logger.severe('databaseError $e');
    //throw HycopException(message: 'databaseError', exception: e as Exception);
    return [];
  }
}