feat(repo): base repository to share a common constructor and logic
This commit is contained in:
@@ -1,10 +1,36 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"forge.capytal.company/loreddev/x/tinyssert"
|
||||
)
|
||||
|
||||
type baseRepostiory struct {
|
||||
db *sql.DB
|
||||
|
||||
ctx context.Context
|
||||
log *slog.Logger
|
||||
assert tinyssert.Assertions
|
||||
}
|
||||
|
||||
func newBaseRepostiory(ctx context.Context, db *sql.DB, log *slog.Logger, assert tinyssert.Assertions) baseRepostiory {
|
||||
assert.NotNil(db)
|
||||
assert.NotNil(ctx)
|
||||
assert.NotNil(log)
|
||||
|
||||
return baseRepostiory{
|
||||
db: db,
|
||||
ctx: ctx,
|
||||
log: log,
|
||||
assert: assert,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ErrDatabaseConn = errors.New("failed to begin transaction/connection with database")
|
||||
ErrExecuteQuery = errors.New("failed to execute query")
|
||||
|
||||
Reference in New Issue
Block a user