We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 422400a commit ac45189Copy full SHA for ac45189
node-registrar/pkg/db/models.go
@@ -1,9 +1,11 @@
1
package db
2
3
import (
4
+ "errors"
5
"time"
6
7
"github.com/lib/pq"
8
+ "gorm.io/gorm"
9
)
10
11
type Account struct {
@@ -55,6 +57,20 @@ type Node struct {
55
57
Approved bool `json:"approved"`
56
58
}
59
60
+func (n *Node) AfterFind(tx *gorm.DB) error {
61
+ if len(n.Interfaces) == 0 {
62
+ return errors.New("interfaces must not be empty")
63
+ }
64
+ return nil
65
+}
66
+
67
+func (n *Node) BeforeCreate(tx *gorm.DB) (err error) {
68
69
70
71
72
73
74
type UptimeReport struct {
75
ID uint64 `gorm:"primaryKey;autoIncrement"`
76
NodeID uint64 `gorm:"index" json:"node_id"`
0 commit comments