mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 06:57:33 +00:00
add documentation
This commit is contained in:
@@ -4,15 +4,7 @@ import (
|
||||
"context"
|
||||
)
|
||||
|
||||
var (
|
||||
db *database
|
||||
)
|
||||
|
||||
type database struct {
|
||||
connector Connector
|
||||
pool Pool
|
||||
}
|
||||
|
||||
// Pool is a connection pool. e.g. pgxpool
|
||||
type Pool interface {
|
||||
Beginner
|
||||
QueryExecutor
|
||||
@@ -21,6 +13,7 @@ type Pool interface {
|
||||
Close(ctx context.Context) error
|
||||
}
|
||||
|
||||
// Client is a single database connection which can be released back to the pool.
|
||||
type Client interface {
|
||||
Beginner
|
||||
QueryExecutor
|
||||
@@ -28,33 +21,37 @@ type Client interface {
|
||||
Release(ctx context.Context) error
|
||||
}
|
||||
|
||||
// Querier is a database client that can execute queries and return rows.
|
||||
type Querier interface {
|
||||
Query(ctx context.Context, stmt string, args ...any) (Rows, error)
|
||||
QueryRow(ctx context.Context, stmt string, args ...any) Row
|
||||
}
|
||||
|
||||
// Executor is a database client that can execute statements.
|
||||
type Executor interface {
|
||||
Exec(ctx context.Context, stmt string, args ...any) error
|
||||
}
|
||||
|
||||
// QueryExecutor is a database client that can execute queries and statements.
|
||||
type QueryExecutor interface {
|
||||
Querier
|
||||
Executor
|
||||
}
|
||||
|
||||
// Scanner scans a single row of data into the destination.
|
||||
type Scanner interface {
|
||||
Scan(dest ...any) error
|
||||
}
|
||||
|
||||
// Row is an abstraction of sql.Row.
|
||||
type Row interface {
|
||||
Scanner
|
||||
}
|
||||
|
||||
// Rows is an abstraction of sql.Rows.
|
||||
type Rows interface {
|
||||
Row
|
||||
Next() bool
|
||||
Close() error
|
||||
Err() error
|
||||
}
|
||||
|
||||
type Query[T any] func(querier Querier) (result T, err error)
|
||||
|
Reference in New Issue
Block a user