-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.go
40 lines (32 loc) · 770 Bytes
/
new.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
package users
import (
"database/sql"
)
// NewNewWithPG return Repository and Authenticator
// using connection to Postgres DB via specified DSN under the hood.
func NewWithPG(dsn string) (Repository, Authenticator, error) {
var (
db *sql.DB
repo Repository
auth Authenticator
err error
)
db, err = openPG(dsn)
repo = newSQLRepo(db)
auth = newBcryptAuth(repo)
return repo, auth, err
}
// NewWithSQLite return Repository and Authenticator
// using SQLite DB with specified path under the hood.
func NewWithSQLite(path string) (Repository, Authenticator, error) {
var (
db *sql.DB
repo Repository
auth Authenticator
err error
)
db, err = openSQlite(path)
repo = newSQLRepo(db)
auth = newBcryptAuth(repo)
return repo, auth, err
}