loadWith<T extends Entity> method

Future<T?> loadWith<T extends Entity>(
  1. Iterable<String>? fields,
  2. T newInstance(
    1. String oid
    ),
  3. String? whereClause, [
  4. Map<String, dynamic>? whereValues,
  5. String? fromClause,
  6. String? shortcut,
  7. AccessOption? option,
])

Loads the first entity of the given criteria, or returns null if none. *

    • whereClause - the where clause.
  • Note: it shall not include where.
  • Example: "$fdType" = 23
    • fromClause - if null, the entity's table is assumed.
  • Note: it shall not include from.
  • Example: "$otTask" inner join "$otGrant"
    • shortcut - the table shortcut to prefix the column names.
  • Default: none. Useful if you joined other tables in fromClause.
  • Note: shortcut is case insensitive.

Implementation

Future<T?> loadWith<T extends Entity>(
    Iterable<String>? fields, T newInstance(String oid),
    String? whereClause, [Map<String, dynamic>? whereValues,
    String? fromClause, String? shortcut, AccessOption? option]) async {
  Set<String>? fds;
  if (fields != null) {
    fds = LinkedHashSet<String>();
    fds..add(fdOid)..addAll(fields);
  }

  final row = await StreamUtil.first(queryFrom(fds,
      fromClause ?? newInstance('*').otype,
      _limit1(whereClause), whereValues, shortcut, option));
    return toEntity(row, fields, newInstance);
}