Live video on the AT Protocol
at issue-784 29 lines 730 B view raw
1package model 2 3import "fmt" 4 5// settings for publishing from a particular key. mostly node-local. 6type Identity struct { 7 ID string `json:"id" gorm:"primaryKey"` 8 Handle string `json:"handle"` 9 DID string `json:"did" gorm:"column:did"` 10} 11 12func (m *DBModel) GetIdentity(id string) (*Identity, error) { 13 var identity Identity 14 err := m.DB.Where("id = ?", id).FirstOrCreate(&identity, Identity{ 15 ID: id, 16 }).Error 17 if err != nil { 18 return nil, fmt.Errorf("error getting settings: %w", err) 19 } 20 return &identity, nil 21} 22 23func (m *DBModel) UpdateIdentity(ident *Identity) error { 24 err := m.DB.Where("id = ?", ident.ID).Save(ident).Error 25 if err != nil { 26 return fmt.Errorf("error updating settings: %w", err) 27 } 28 return nil 29}