select method

  1. @override
Future<DbResult> select(
  1. String table, {
  2. Map<String, dynamic>? where,
  3. int? limit,
  4. int? offset,
})
override

Retrieves data from the specified table.

  • where: Optional filter conditions (e.g., {'id': 1}).

Implementation

@override
Future<DbResult> select(
  String table, {
  Map<String, dynamic>? where,
  int? limit,
  int? offset,
}) async {
  var query = 'SELECT * FROM $table';
  final params = <String, dynamic>{};

  if (where != null && where.isNotEmpty) {
    final conditions = where.entries
        .map((e) => '${e.key} = ${ph(e.key)}')
        .join(' AND ');
    query += ' WHERE $conditions';
    params.addAll(where);
  }

  if (limit != null) query += ' LIMIT $limit';
  if (offset != null) query += ' OFFSET $offset';

  return rawQuery(query, values: params.isEmpty ? null : params);
}