create method

Future<R> create(
  1. Model parent,
  2. DatabaseManager db,
  3. Map<String, Object?> attributes
)

Creates a related model with the foreign key set.

Implementation

Future<R> create(
  Model parent,
  DatabaseManager db,
  Map<String, Object?> attributes,
) async {
  final model = related.newInstance(attributes, db)
    ..setAttr(foreignKey, parent.attributes[localKey]);
  await model.save();
  return model;
}