How do I execute a function every time a node is being updated? I tried to use hook_nodeapi, but it looks like that the hook is removed from Drupal 7.
What I want to do is,
to do this, I need to make sure that there is always only one node with 'main image' set to true.
Currently Drupal core does not offer any hook to do actions after a node/entity is inserted/updated/deleted in Database. For example, you can not send an email mentioning the node after the node is inserted because Drupal uses SQL transactions and the node is not yet fully written to database when hook node presave is called so if for any reason the transaction is rolled back, users will receive a false mail.
So Hook Post Action module introduces several new Drupal hooks to overcome this limitation: