store

package
v0.0.0-...-d35a86b Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBProvider

type DBProvider interface {
	DB(ctx context.Context) *gorm.DB
}

DBProvider is a marker interface for database providers.

type Logger

type Logger interface {
	// Log logs a message at the specified level.
	Error(err error, message string, kvs ...any)
}

type Option

type Option[T any] func(*Store[T])

Option defines a function type for configuring the Store.

func WithLogger

func WithLogger[T any](logger Logger) Option[T]

Logger is a generic logger.

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

Store is a generic store.

func NewStore

func NewStore[T any](storage DBProvider, logger Logger) *Store[T]

NewStore creates a new store.

func (*Store[T]) Create

func (s *Store[T]) Create(ctx context.Context, obj *T) error

Create inserts a new record into the database.

func (*Store[T]) Delete

func (s *Store[T]) Delete(ctx context.Context, opts *where.WhereOptions) error

Get retrieves a record from the database.

func (*Store[T]) Get

func (s *Store[T]) Get(ctx context.Context, opts *where.WhereOptions) (*T, error)

func (*Store[T]) List

func (s *Store[T]) List(ctx context.Context, opts *where.WhereOptions) (count int64, ret []*T, err error)

func (*Store[T]) Update

func (s *Store[T]) Update(ctx context.Context, obj *T, wheres ...where.Where) error

Directories

Path Synopsis
logger

Jump to

Keyboard shortcuts

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