hasOne method

Future<B?> hasOne(
  1. A model
)

Implementation

Future<B?> hasOne(A model) async {
  List<dynamic> models = await Collection.get(modelType: B)
      .where('${Model.typeToId(A)}_id', model.getId());

  if (models.isEmpty) {
    return null;
  }

  return models.first;
}