What are server hooks?

Server hooks are scripts on the server side that get executed automatically exactly before or after (pre-save or post-save) creating or updating an entity in a collection.

The two types of server hooks you can define for a collection are:

  • Pre Save: Triggers before an entity is created or updated.
  • Post Save: Triggers after an entity is created or updated.

These can be useful to calculate an extra field with some of the fields in the entity or to validate the expected data (if the entity is not filled correctly, you can reject the request and avoid storing wrong data).

You can find a couple of server hook examples here in the Server Code guide.

Keep in mind that Pre Save server hooks will be executed before Gamedonia API Response, so they have an impact on the execution time. This doesn't happen with the Post Save server hooks.

More info here: Server code guide