'GORM Database.First(&tableStruct, id) without deleted_at IS NULL
When tableStruct have gorm.Model inside, how to get first record by id without gorm automatically adding deleted_at IS NULL? Is there such function?
Solution 1:[1]
After reading the source code, there are Unscoped method to prevent adding deleted_at IS NULL
Database.Unscoped().First(&tableStruct, id)
Solution 2:[2]
best answer here : https://gorm.io/docs/delete.html#Find-soft-deleted-records
db.Unscoped().First(&tableStruct, id)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kokizzu |
| Solution 2 | Barnando Akbarto Hidayatullah |
