ComputedField.first constructor

ComputedField.first(
  1. String field, {
  2. required String from,
  3. Map<String, dynamic>? where,
  4. Map<String, String>? orderBy,
})

Create a FIRST (single value) computed field.

Fetches the first matching value with optional ordering.

ComputedField.first('priceCurrency',
  from: 'Plan',
  where: {'consultantId': FieldRef('id')},
  orderBy: {'price': 'asc'})
// Generates: (SELECT "priceCurrency" FROM "Plan" WHERE ... ORDER BY "price" ASC LIMIT 1)

Implementation

factory ComputedField.first(
  String field, {
  required String from,
  Map<String, dynamic>? where,
  Map<String, String>? orderBy,
}) {
  return ComputedField._(
    field: field,
    operation: AggregateOp.first,
    from: from,
    where: where,
    orderBy: orderBy,
  );
}