load method

  1. @override
FutureOr<Map<String, dynamic>?> load(
  1. Entity entity,
  2. Iterable<String>? fields,
  3. AccessOption? option
)
override

Loads the data of the given OID. *

    • fields - a collection of fields to load. If null, it means all.
  • If the plugin doesn't support partial load, it can ignore fields.
  • Note: it shall return a Future carrying null if not found.
    • option - an option for loading the entity.
  • It is the option passed from load and loadIfAny.
  • It can be application specific.
  • You can ignore it if not supported.
  • For SQL, it is better to supported null, forShare and forUpdate.

Implementation

@override
FutureOr<Map<String, dynamic>?> load(Entity entity, Iterable<String>? fields,
    AccessOption? option) {
  final data = _load(entity.oid);
  if (data != null) {
    assert(data[fdOtype] == entity.otype);
    _cache.put(entity); //update cache
  }
  return Future.value(data);
}