-
-
Notifications
You must be signed in to change notification settings - Fork 367
Open
Labels
Description
Document Link
Your Question
The documentation doesn't state what the AfterDelete hook receives in the struct that is provided to the hook.
eg. If you issue a Delete(struct, id) then AfterDelete gets the struct, but NOT the id.
Expected answer
Clear documentation on what GORM provides in the struct passed to the hook.
- Use Case 1 - Struct populated with ID
- AfterDelete is called ONCE and receives the struct with ID (and other fields if provided), UpdatedAt, and DeletedAt populated
- Use Case 2 - Struct without ID, and list of ID(s) provided in delete conditions
- AfterDelete is called ONCE and receives the struct without ID (but other fields if provided), UpdatedAt, and DeletedAt populated
- Use Case 3 - Empty Struct, Delete using Where clause
- AfterDelete is called ONCE and receives a struct with UpdatedAt, and DeletedAt populated
See go-gorm/playground#792 for example tests that show some of the ways that you can execute a delete.