Prevent record update

This example shows you how to prevent updating records based on specific criteria. Here, shipped orders should not be editable. We will notify the user with a customized error message.

Requirements

  • An admin backend running on forest-express-sequelize

How it works

Directory: /models

This directory contains the orders.js file where the model is declared.

Directory: /routes

This directory contains the orders.js file where the routes are declared.

We override the update route so it sends an error as a response when the shippingStatus is either Shipped or In transit. Otherwise, it triggers the default logic with next().

Last updated

Was this helpful?