afterRemove( )

A hook that is triggered after a remove() operation.

The afterRemove() hook runs when:

  • The remove() function is called.
  • An action is performed on a dataset that removes an item from the collection.
  • An item is deleted using the CMS.

Return an object or a Promise that resolves to an object. The returned object will be used as the result of the call to the remove() function instead of the actual item removed from the collection. If returning a Promise, the object is used as the result, whether the Promise is fulfilled or rejected.

If the returned value is of the wrong type, the value is ignored.

A rejected Promise also calls the onFailure() hook if it has been registered.

Because the afterRemove() hook is called after the remove() is executed, it cannot prevent the item from being removed from the collection. It can only affect the item returned by remove().

Method Declaration
Method Parameters

The item that was removed.


Contextual information about the hook.

Return Type:Promise<object> | object
Was this helpful?