-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.go
37 lines (30 loc) · 781 Bytes
/
db.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
package db
import (
"context"
"github.com/ViBiOh/auth/v2/pkg/auth"
"github.com/ViBiOh/auth/v2/pkg/ident/basic"
"github.com/jackc/pgx/v5"
)
//go:generate mockgen -source db.go -destination ../../mocks/db.go -package mocks -mock_names Database=Database
// Database interface needed
type Database interface {
Get(context.Context, func(pgx.Row) error, string, ...any) error
Create(context.Context, string, ...any) (uint64, error)
One(context.Context, string, ...any) error
DoAtomic(context.Context, func(context.Context) error) error
}
// App of package
type App struct {
db Database
}
var (
_ auth.Provider = App{}
_ auth.Storage = App{}
_ basic.Provider = App{}
)
// New creates new App from dependencies
func New(db Database) App {
return App{
db: db,
}
}