/
hgeographi.go
68 lines (57 loc) · 1.2 KB
/
hgeographi.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gdrj
import (
"errors"
"github.com/eaciit/orm/v1"
"github.com/eaciit/toolkit"
)
//
// ID
// Region
// Zone
// National
type HGeographi struct {
orm.ModelBase `json:"-" bson:"-"`
ID string `json:"_id" bson:"_id"` //Area
Location string
Region string
Zone string
National string
}
func (h *HGeographi) RecordID() interface{} {
return h.ID
}
func (h *HGeographi) TableName() string {
return "hgeographi"
}
func HGeographiGetByID(id string) *HGeographi {
b := new(HGeographi)
DB().GetById(b, id)
return b
}
func HGeographiGetAll() ([]*HGeographi, error) {
cursor, err := DB().Find(new(HGeographi), nil)
if err != nil {
return nil, err
}
result := []*HGeographi{}
err = cursor.Fetch(&result, 0, false)
if err != nil {
return nil, err
}
cursor.Close()
return result, nil
}
func (h *HGeographi) Save() error {
err := Save(h)
if err != nil {
return errors.New(toolkit.Sprintf("[%v-%v] Error found : %v ", h.TableName(), "save", err.Error()))
}
return err
}
func (h *HGeographi) Delete() error {
err := Delete(h)
if err != nil {
return errors.New(toolkit.Sprintf("[%v-%v] Error found : %v ", h.TableName(), "delete", err.Error()))
}
return err
}