Gorm Gotchas
Hey, thanks for the article!
I was wondering how are you supposed to use Article and Tag if you declare them inside the migration, do you re-declare them outside of the migration or what is your approach?
@shackra Hey, thanks for the article!
I was wondering how are you supposed to use Article and Tag if you declare them inside the migration, do you re-declare them outside of the migration or what is your approach?
Hey :) Thanks for your feedback. You declare them both in your migration and in your model. This way, your migrations are not tied with your model.
Not sure if it has changed with gorm version, but this,
MetaDataB postgres.Jsonb `gorm:"type:jsonb;"
seems to not work anymore.
MetaDataB json.RawMessage `gorm:"type:jsonb;"`
works
Hey.
I'll give that a try when I'll have time, but at the time of writing this did work. I'm surprised that json.RawMessage would work. Under the hood, postgres.Jsonb is effectively a json.RawMessage but it also implements the sql.Scanner and driver.Valuer interfaces so that gorm can effectively use this type as you can see in the source code of Gorm
Thanks a lot for your feedback on my post!