withChild<Z extends DataClass> method

DataSet<T> withChild<Z extends DataClass>(
  1. DataSet<Z> child, [
  2. String identifier = 'default'
])

This method registers a DataSet that will have direct relation to the dataset already instantiated. For that, it uses a relation name as a key for retrieving it later

Implementation

DataSet<T> withChild<Z extends DataClass>(DataSet<Z> child,
    [String identifier = 'default']) {
  if (_children[Z] != null) {
    if (_children[Z]!.containsKey(identifier)) {
      throw Exception(
          'Cannot insert two datasets of the type ${child.modelName} with the same identifier $identifier');
    }
    _children[Z]![identifier] = child;
  } else {
    _children[Z] = {identifier: child};
  }
  return this;
}