updateObject method

  1. @Operation("id")
Future<Response> updateObject(
  1. @Bind("id") String id
)

Implementation

@Operation.put("id")
Future<Response> updateObject(@Bind.path("id") String id) async {
  var primaryKey = _query!.entity.primaryKey;
  final parsedIdentifier =
      _getIdentifierFromPath(id, _query!.entity.properties[primaryKey]!);
  _query!.where((o) => o[primaryKey!]).equalTo(parsedIdentifier);

  final instance = _query!.entity.instanceOf() as InstanceType;
  instance.readFromMap(request!.body!.as());
  _query!.values = instance;

  _query = await willUpdateObjectWithQuery(_query!);

  var results = await _query?.updateOne();
  if (results == null) {
    return didNotFindObjectToUpdateWithID(id);
  } else {
    return didUpdateObject(results);
  }
}