tommybananas / finale

Create flexible REST endpoints and controllers from Sequelize models in your Express app
188 stars 36 forks source link

Instance removed from context on DELETE #34

Closed awm33 closed 2 years ago

awm33 commented 6 years ago

For DELETES, in this line https://github.com/tommybananas/finale/blob/master/lib/Controllers/delete.js#L23 the instance is removed from the context, which greatly limits what can be done in hooks after write.

A temp solution I have is backing up the instance in another hook, but this seems to be limiting. Sequelize destroy hooks still retain the instance in memory so that hooks can use information on the newly deleted instance.

The use case here is pretty common, creating an event from the event. Another common use case would be calling a third party service, like S3 to delete related blob items.

Could we either 1) Remove that line 2) Move the instance to something like context.deletedInstance?

tommybananas commented 5 years ago

I'd be happy to include this if you can you create a pull request, thanks!

tommybananas commented 5 years ago

Couldn't you also just add that property to the context in a prior milestone?

RRozza commented 2 years ago

Solved here