findByIndex method

Future<List<Row>> findByIndex(
  1. String column,
  2. dynamic value
)

Index lookup.

Implementation

Future<List<Row>> findByIndex(String column, dynamic value) async {
  final tree = indexes[column];
  if (tree == null) {
    return (await scan()).where((r) => r[column] == value).toList();
  }
  final ids = tree.search(value).toSet();
  if (ids.isEmpty) return [];
  return (await scan()).where((r) => ids.contains(r.id)).toList();
}