How do I stop gorm from complaining about deleted_at field. I know I can use plain struct without gorm.Model but that would mean I cant add relations to user/other structs… eg I cannot declare user has one language association in User struct if I dont add gorm.Model but if I add, it would complain about deleted_at field which of course doesnt exist. any help is really appreciated. I have tried some combination of tags eg I added DeletedAt field and give it tags 1. gorm: “-” and then I also tried json: “-” to ignore it, but still no luck This seems very small basic but I couldnt figure sorry I am newbie in golang.
I found my answer in the conventions of gorm docs
I've just created my own base model instead using gorm.Model and didnt use deleted_at field on it. And it worked perfectly.
Edit: And seems that I was wrong, I can have any base struct and associations will work. Just dont user gorm.Model as base Model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With