query method

Future<List<Map>> query (BeanStorageProvider storageProvider, { Map<String, dynamic> filter, Map<String, dynamic> exclude, bool distinct, List<String> columns, String where, List whereArgs, String groupBy, String having, String orderBy, int limit, int offset })

Implementation

Future<List<Map>> query(BeanStorageProvider storageProvider,
    {Map<String, dynamic> filter,
    Map<String, dynamic> exclude,
    bool distinct,
    List<String> columns,
    String where,
    List whereArgs,
    String groupBy,
    String having,
    String orderBy,
    int limit,
    int offset}) async {
  if (filter != null) {
    where ??= "";
    whereArgs ??= [];
    List<String> whereKeys = [];
    filter.forEach((k, v) {
      whereKeys.add("$k == ?");
      whereArgs.add(v);
    });
    where += " " + whereKeys.join(" and ");
  }
  if (exclude != null) {
    where ??= "";
    whereArgs ??= [];
    List<String> excludeKeys = [];
    exclude.forEach((k, v) {
      excludeKeys.add("$k != ?");
      whereArgs.add(v);
    });
    where += " and " + excludeKeys.join(" and ");
  }
  return storageProvider.getRawList(
    distinct: distinct,
    columns: columns,
    where: where,
    whereArgs: whereArgs,
    groupBy: groupBy,
    having: having,
    orderBy: orderBy,
    limit: limit,
    offset: offset,
  );
}