-
Notifications
You must be signed in to change notification settings - Fork 23
/
ovconfig.go
46 lines (39 loc) · 849 Bytes
/
ovconfig.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package models
import (
"github.com/astaxie/beego/orm"
"github.com/bnhf/go-openvpn/server/config"
)
//OVConfig holds values for OpenVPN config file
type OVConfig struct {
Id int
Profile string `orm:"size(64);unique" valid:"Required;"`
config.Config
}
//Insert wrapper
func (c *OVConfig) Insert() error {
if _, err := orm.NewOrm().Insert(c); err != nil {
return err
}
return nil
}
//Read wrapper
func (c *OVConfig) Read(fields ...string) error {
if err := orm.NewOrm().Read(c, fields...); err != nil {
return err
}
return nil
}
//Update wrapper
func (c *OVConfig) Update(fields ...string) error {
if _, err := orm.NewOrm().Update(c, fields...); err != nil {
return err
}
return nil
}
//Delete wrapper
func (c *OVConfig) Delete() error {
if _, err := orm.NewOrm().Delete(c); err != nil {
return err
}
return nil
}