mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
e269b37b0e
fix: database cascade settings chore: debug log mode for gorm queries is back
22 lines
745 B
Go
22 lines
745 B
Go
package models
|
|
|
|
type LanguageMapping struct {
|
|
ID uint `json:"id" gorm:"primary_key"`
|
|
User *User `json:"-" gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
|
|
UserID string `json:"-" gorm:"not null; index:idx_language_mapping_user; uniqueIndex:idx_language_mapping_composite"`
|
|
Extension string `json:"extension" gorm:"uniqueIndex:idx_language_mapping_composite; type:varchar(16)"`
|
|
Language string `json:"language" gorm:"type:varchar(64)"`
|
|
}
|
|
|
|
func (m *LanguageMapping) IsValid() bool {
|
|
return m.validateLanguage() && m.validateExtension()
|
|
}
|
|
|
|
func (m *LanguageMapping) validateLanguage() bool {
|
|
return len(m.Language) >= 1
|
|
}
|
|
|
|
func (m *LanguageMapping) validateExtension() bool {
|
|
return len(m.Extension) >= 1
|
|
}
|