code: def replace(self, identifier, new_instance):
          
          try:
              # Note that `self.update()` ultimately calls merge, which will not enforce
              # a strict replacement; absent fields will default to the current values.
              return self.update(identifier, new_instance)
          except ModelNotFoundError:
              return self.create(new_instance)
docs: Create or update a model.