updateObject method Null safety

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

Implementation

@Operation.put("id")
Future<Response> updateObject(@Bind.path("id") String id) async {
  final 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);

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