afterUpdate( )


A hook that is triggered after an update() operation.

The afterUpdate() hook runs when:

  • The update() function is called.
  • An action is performed on a dataset that updates an item from the collection.
  • An item is updated using the CMS.

Return an object or a Promise that resolves to an object from the afterUpdate() function. The returned object will be used as the result of the call to the update() function instead of the actual item updated in 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 afterUpdate hook is called after the update() is executed, it cannot affect the item that is being updated in the collection. It can only affect the item returned by update().

Method Declaration
Copy
Method Parameters
itemobjectRequired

The updated item.


contextUpdateHookContextRequired

Contextual information about the hook.

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