hydrate<_Model extends SqliteModel> method

List<_Model> hydrate<_Model extends SqliteModel>(
  1. List<_Model> models
)

Replenish managedObjects with new data. Any one of the models with a null .primaryKey will not be inserted. This avoids unexpected null collisions.

For convenience, the return value is the argument models, not the complete set of managed _Models. If the managed models are desired instead, use get.

Implementation

List<_Model> hydrate<_Model extends SqliteModel>(List<_Model> models) {
  if (!manages(_Model)) return models;
  managedObjects[_Model] ??= {};

  for (final instance in models) {
    if (instance.primaryKey != null) {
      managedObjects[_Model]![instance.primaryKey!] = instance;
    }
  }

  return models;
}