I was trying forever to get autoloading relationships working with postgres 9.4 and gorm and primary keys of type uuid.
Many tutorials and examples, even those on the official docs were just not workiong or missing important details.
The program in this gist creates the table structure and inserts a nested record. A parent and a child object is created by simply creating the child, which holds the relation to a parent. The child element then is queried by ID. The returned object holds the nested parent object.
Used package versions:
- github.com/jinzhu/gorm v1.9.1 6ed508ec6a4ecb3531899a69cbc746ccf65a4166
- github.com/satori/go.uuid v1.2.0 f58768cc1a7a7e77a3bd49e98cdd21419399b6a3
@gipsh Thank you so much! Save my day!