-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
79 lines (63 loc) · 1.17 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/gobuffalo/pop"
"github.com/gofrs/uuid"
"github.com/jamescyeh/gobuffalo/models"
)
func main() {
eager()
// noteager()
}
func eager() {
c, err := pop.Connect("development")
if err != nil {
fmt.Println("could not connect to db")
return
}
// [...]
u1, _ := uuid.NewV4()
u2, _ := uuid.NewV4()
fmt.Println(u1)
fmt.Println(u2)
job_one := &models.Job{
ID: u2,
}
group := &models.Group{
ID: u1,
Jobs: []models.Job{*job_one},
}
err = c.Eager().Create(group)
spew.Dump(err)
outputGroup := models.Group{}
err = c.Eager().Find(&outputGroup, u1)
spew.Dump(err)
spew.Dump(outputGroup)
}
func noteager() {
c, err := pop.Connect("development")
if err != nil {
fmt.Println("could not connect to db")
return
}
u1, _ := uuid.NewV4()
u2, _ := uuid.NewV4()
fmt.Println(u1)
fmt.Println(u2)
group := &models.Group{
ID: u1,
}
job_one := &models.Job{
ID: u2,
GroupID: u1,
}
err = c.Create(group)
spew.Dump(err)
err = c.Create(job_one)
spew.Dump(err)
outputGroup := models.Group{}
err = c.Eager().Find(&outputGroup, u1)
spew.Dump(err)
spew.Dump(outputGroup)
}