-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdb.go
More file actions
51 lines (42 loc) · 1002 Bytes
/
db.go
File metadata and controls
51 lines (42 loc) · 1002 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package database
import (
pg "github.com/go-pg/pg"
)
// Handle is a database handle.
type Handle struct {
*pg.DB
opts Options
}
// Options is a set of options for connecting to PostgreSQL.
type Options struct {
Addr string
User string
Password string
Database string
}
// Open opens a new database connection.
func Open(opts Options) *Handle {
db := pg.Connect(&pg.Options{
Addr: opts.Addr,
User: opts.User,
Password: opts.Password,
Database: opts.Database,
})
return &Handle{db, opts}
}
// NewFilerDao returns a filer dao.
func (h *Handle) NewFilerDao() *FilerDaoImpl {
return &FilerDaoImpl{db: h}
}
// NewFormDao returns a form dao.
func (h *Handle) NewFormDao() *FormDaoImpl {
return &FormDaoImpl{db: h}
}
// NewFilingDao returns a filing dao.
func (h *Handle) NewFilingDao() *FilingDaoImpl {
return &FilingDaoImpl{db: h}
}
// NewDocumentDao returns a document dao.
func (h *Handle) NewDocumentDao() *DocumentDaoImpl {
return &DocumentDaoImpl{db: h}
}