replaceToOne method

Future<RelationshipUpdated<ToOne>> replaceToOne(
  1. String type,
  2. String id,
  3. String relationship,
  4. Identifier identifier, {
  5. Map<String, Object?> meta = const {},
  6. Map<String, List<String>> headers = const {},
  7. Iterable<QueryEncodable> query = const [],
})

Replaces the to-one relationship identified by type, id, and relationship by setting the new identifier.

Optional arguments:

  • meta - relationship metadata
  • headers - any extra HTTP headers
  • query - a collection of parameters to be included in the URI query

Implementation

Future<RelationshipUpdated<ToOne>> replaceToOne(
  String type,
  String id,
  String relationship,
  Identifier identifier, {
  Map<String, Object?> meta = const {},
  Map<String, List<String>> headers = const {},
  Iterable<QueryEncodable> query = const [],
}) async =>
    RelationshipUpdated.one(await send(
        _baseUri.relationship(type, id, relationship),
        Request.patch(
            OutboundDataDocument.one(ToOne(identifier)..meta.addAll(meta)))
          ..headers.addAll(headers)
          ..query.mergeAll(query)));