query method

Future<List<Map<String, dynamic>>?> query(
  1. String? q, {
  2. bool verbose = false,
})

Execute a query

Implementation

Future<List<Map<String, dynamic>>?> query(String? q,
    {bool verbose = false}) async {
  /// [q] the query to execute
  try {
    if (!_isReady) {
      throw DatabaseNotReady();
    }
    final timer = Stopwatch()..start();
    List<Map<String, dynamic>>? res;
    await _db!.transaction((txn) async {
      res = await txn.rawQuery(q!);
    }).catchError((dynamic e) =>
        throw RawQueryException("Can not execute query $q $e"));
    timer.stop();
    if (verbose) {
      final msg = "$q in ${timer.elapsedMilliseconds} ms";
      print(msg);
    }
    return res;
  } catch (e) {
    rethrow;
  }
}