forked from gomods/athens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdbms.go
31 lines (27 loc) · 780 Bytes
/
rdbms.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
package rdbms
import (
"github.com/gobuffalo/pop"
)
// MetadataStore represents a rdbms(postgres, mysql, sqlite, cockroachdb) backed metadata store.
type MetadataStore struct {
conn *pop.Connection
connectionName string // settings name from database.yml
}
// NewStorage returns an unconnected RDBMS Metadata Storage
// that satisfies the Getter and Setter interfaces. You must call
// Connect() on the returned store before using it.
// connectionName
func NewStorage(connectionName string) *MetadataStore {
return &MetadataStore{
connectionName: connectionName,
}
}
// Connect creates connection to rdmbs backend.
func (r *MetadataStore) Connect() error {
c, err := pop.Connect(r.connectionName)
if err != nil {
return err
}
r.conn = c
return nil
}