toListWhereColumnHasValue method

Future<List<ISQLiteItem>> toListWhereColumnHasValue(
  1. ISQLiteItem item,
  2. String columnName,
  3. dynamic columnValueOf, {
  4. int? limit,
})

Implementation

Future<List<ISQLiteItem>> toListWhereColumnHasValue(
    ISQLiteItem item, String columnName, dynamic columnValueOf,
    {int? limit}) async {
  String tableName = item.getTableName();
  List<ISQLiteItem> results = [];
  var db = await getOpenDatabase();

  String condition = '$columnName = ?';

  var maps = await db.query(
    tableName,
    where: condition,
    whereArgs: [columnValueOf], // Pass the value as an array
    limit: limit,
  );

  // Map the results to items
  results = maps.map((map) => item.fromMap(map)).toList();

  return results;
}