beforeUpdate( )


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

The beforeUpdate() 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.

The hook also runs when an action is performed on a dataset that updates an item from the collection that the dataset is connected to.

Return an object or a Promise that resolves to an object from the beforeUpdate() function. The returned object will be updated in the collection instead of the original item passed to the update() function.

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

A rejected Promise blocks the call to update() and also calls the onFailure() hook if it has been registered.

Because the beforeUpdate() hook is called before the update() is executed, it can affect the item that is updated in the collection or block the update().

Method Declaration
Copy
Method Parameters
itemobjectRequired

The original item to be updated.


contextUpdateHookContextRequired

Contextual information about the hook.

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