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}).
  • limit / offset: SQL-side pagination.

For sorting or richer filters use the fluent builder: db.query(table)....

Implementation

@override
Future<DbResult> select(
  String table, {
  Map<String, dynamic>? where,
  int? limit,
  int? offset,
}) async {
  var sql = 'SELECT * FROM $table';
  if (where != null && where.isNotEmpty) {
    final cond = where.keys.map((k) => '$k = ?').join(' AND ');
    sql += ' WHERE $cond';
  }
  if (limit != null) {
    sql += ' LIMIT $limit';
    if (offset != null) sql += ' OFFSET $offset';
  } else if (offset != null) {
    // SQLite requires LIMIT when OFFSET is present; -1 means unlimited.
    sql += ' LIMIT -1 OFFSET $offset';
  }
  return _run(_db, '$sql;', where == null || where.isEmpty ? null : where);
}