query method

QueryBuilder query()

Internal query builder instance for chaining Execute the query and get results - FIXED Get first result - FIXED Custom query builder - starts a new chain

Implementation

// ========== CHAINABLE QUERY METHODS ==========

// static final Map<String, RelationLoader> _relationLoaders = {};

/// Execute the query and get results - FIXED
// Future<List<T>> get() async {
//   final rows = await qb.get();

//   final models =
//       rows.map((map) => fromMap(_convertDatabaseTypes(map))).toList();

//   // Load relations if any are specified
//   if (qb.relations.isNotEmpty) {
//     final modelClassName = runtimeType.toString();

//     // Get the withRelations config from QueryBuilder
//     // We need to access it - you might need to add a getter in QueryBuilder
//     final relationConfigs =
//         qb.withRelations; // Add this getter to QueryBuilder

//     await loadRelations(models.cast<Model>(), qb.relations, modelClassName);
//   }

//   resetQuery();
//   return models;
// }

/// Get first result - FIXED
// Future<T?> first() async {
//   final result = await qb.first();
//   resetQuery();

//   if (result == null) return null;

//   final model = fromMap(_convertDatabaseTypes(result));

//   // Load relations for single model
//   if (qb.relations.isNotEmpty) {
//     final modelClassName = runtimeType.toString();
//     final relationConfigs = qb.withRelations;

//     await loadRelations([model as Model], qb.relations, modelClassName);
//   }

//   return model;
// }

/// Custom query builder - starts a new chain
QueryBuilder query() {
  return qb;
}