···11+package model
22+33+import "gorm.io/gorm/clause"
44+55+type Label struct {
66+ // cid: Optionally, CID specifying the specific version of 'uri' resource this label applies to.
77+ Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty" gorm:"column:cid"`
88+ // cts: Timestamp when this label was created.
99+ Cts string `json:"cts" cborgen:"cts" gorm:"column:cts"`
1010+ // exp: Timestamp at which this label expires (no longer applies).
1111+ Exp *string `json:"exp,omitempty" cborgen:"exp,omitempty" gorm:"column:exp"`
1212+ // neg: If true, this is a negation label, overwriting a previous label.
1313+ Neg *bool `json:"neg,omitempty" cborgen:"neg,omitempty" gorm:"column:neg"`
1414+ // sig: Signature of dag-cbor encoded label.
1515+ Sig []byte `json:"sig,omitempty" cborgen:"sig,omitempty" gorm:"column:sig"`
1616+ // src: DID of the actor who created this label.
1717+ Src string `json:"src" cborgen:"src" gorm:"primaryKey;column:src"`
1818+ // uri: AT URI of the record, repository (account), or other resource that this label applies to.
1919+ Uri string `json:"uri" cborgen:"uri" gorm:"primaryKey;column:uri;index"`
2020+ // val: The short string name of the value or type of this label.
2121+ Val string `json:"val" cborgen:"val" gorm:"primaryKey;column:val"`
2222+ // ver: The AT Protocol version of the label object.
2323+ Ver *int64 `json:"ver,omitempty" cborgen:"ver,omitempty" gorm:"column:ver"`
2424+2525+ Record []byte `json:"record,omitempty" cborgen:"record,omitempty" gorm:"column:record"`
2626+}
2727+2828+func (m *DBModel) CreateLabel(label *Label) error {
2929+ return m.DB.Clauses(clause.OnConflict{
3030+ Columns: []clause.Column{
3131+ {Name: "src"},
3232+ {Name: "uri"},
3333+ {Name: "val"},
3434+ },
3535+ UpdateAll: true,
3636+ }).Create(label).Error
3737+}