forked from ezdapps/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeys.go
More file actions
32 lines (27 loc) · 645 Bytes
/
keys.go
File metadata and controls
32 lines (27 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package model
import (
"fmt"
)
// Key is model
type Key struct {
tableName string
ID int64 `gorm:"primary_key;not null"`
PublicKey []byte `gorm:"column:pub;not null"`
Amount string `gorm:"not null"`
}
// SetTablePrefix is setting table prefix
func (m *Key) SetTablePrefix(prefix int64) *Key {
if prefix == 0 {
prefix = 1
}
m.tableName = fmt.Sprintf("%d_keys", prefix)
return m
}
// TableName returns name of table
func (m Key) TableName() string {
return m.tableName
}
// Get is retrieving model from database
func (m *Key) Get(wallet int64) (bool, error) {
return isFound(DBConn.Where("id = ?", wallet).First(m))
}