database

package
v0.0.0-...-74f510f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb(cfg config.DataBaseConfig) (*sql.DB, error)

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

func (*Database) GetUserByEmail

func (c *Database) GetUserByEmail(
	ctx context.Context,
	request *dbtypes.GetUserByEmailRequest,
) (*dbtypes.GetUserResponse, error)

func (*Database) GetUserById

func (*Database) Register

func (c *Database) Register(
	ctx context.Context,
	request *dbtypes.RegisterRequest,
) (*dbtypes.RegisterResponse, error)

type Driver

type Driver interface {
	// QueryContext executes a query that returns rows, typically a SELECT.
	// The args are for any placeholder parameters in the query.
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

	// QueryRowContext executes a query that is expected to return at most one row.
	// QueryRowContext always returns a non-nil value. Errors are deferred until
	// [Row]'s Scan method is called.
	// If the query selects no rows, the [*Row.Scan] will return [ErrNoRows].
	// Otherwise, [*Row.Scan] scans the first selected row and discards
	// the rest.
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

	// ExecContext executes a query without returning any rows.
	// The args are for any placeholder parameters in the query.
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

type Repository

type Repository interface {
	Register(ctx context.Context, request *dbtypes.RegisterRequest) (*dbtypes.RegisterResponse, error)

	GetUserByEmail(ctx context.Context, request *dbtypes.GetUserByEmailRequest) (*dbtypes.GetUserResponse, error)
	GetUserById(ctx context.Context, request *dbtypes.GetUserInfoByIdRequest) (*dbtypes.GetUserInfoByIdResponse, error)
}

func New

func New(db *sql.DB) Repository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL