Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Created November 27, 2020 15:56
Show Gist options
  • Save dipeshhkc/a5fc6b12b944df62b07b1baca9f631b6 to your computer and use it in GitHub Desktop.
Save dipeshhkc/a5fc6b12b944df62b07b1baca9f631b6 to your computer and use it in GitHub Desktop.
// Post is the model for the posts table.
type Post struct {
ID MYTYPE `gorm:"primary_key;default:(UUID_TO_BIN(UUID()));"`
Name string `gorm:"not null"`
Comment Comment
}
// Comment is the model for the comments table.
type Comment struct {
ID MYTYPE `gorm:"primary_key;default:(UUID_TO_BIN(UUID()));"`
Name string `gorm:"size:128;not null;"`
PostID MYTYPE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment