orm

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Lens scene.CompositionName = "orm"

Variables

This section is empty.

Functions

func GormDialectorMySql added in v0.3.2

func GormDialectorMySql(ds datasource.MysqlDataSource) gorm.Dialector

func GormDialectorSqlite added in v0.3.2

func GormDialectorSqlite(ds datasource.SqliteDataSource) gorm.Dialector

Types

type GenericRepository added in v0.2.8

type GenericRepository[Model any] interface {
	Create(data *Model) error
	Update(updates any, options ...query.Option) error
	Upsert(data *Model, conflictKeys []query.Field, updateKeys []query.Field) error
	Delete(options ...query.Option) error
	FindFirst(options ...query.Option) (data Model, found bool, err error)
	Count(options ...query.Option) (count int64, err error)
	List(offset, limit int64, options ...query.Option) (model.PaginationResult[Model], error)
	// WithTx Transaction 事务支持
	WithTx(fn func(repo GenericRepository[Model]) error) error
	WithContext(ctx context.Context) GenericRepository[Model]
}

type Gorm

type Gorm interface {
	ORM
	query.QueryBuilder[*gorm.DB]
	DB() *gorm.DB
	RegisterModel(model ...any) error
	WithDB(db *gorm.DB) Gorm
}

type GormRepository added in v0.2.8

type GormRepository[Model any] struct {
	// contains filtered or unexported fields
}

func NewGormRepository added in v0.2.8

func NewGormRepository[Model any](
	db Gorm, fieldMapper query.FieldMapper) *GormRepository[Model]

func (*GormRepository[Model]) Count added in v0.2.8

func (g *GormRepository[Model]) Count(options ...query.Option) (count int64, err error)

func (*GormRepository[Model]) Create added in v0.2.8

func (g *GormRepository[Model]) Create(data *Model) error

func (*GormRepository[Model]) Delete added in v0.2.8

func (g *GormRepository[Model]) Delete(options ...query.Option) error

func (*GormRepository[Model]) FindFirst added in v0.2.8

func (g *GormRepository[Model]) FindFirst(options ...query.Option) (data Model, found bool, err error)

func (*GormRepository[Model]) List added in v0.2.8

func (g *GormRepository[Model]) List(offset, limit int64, options ...query.Option) (model.PaginationResult[Model], error)

func (*GormRepository[Model]) Setup added in v0.2.8

func (g *GormRepository[Model]) Setup() error

func (*GormRepository[Model]) Update added in v0.2.8

func (g *GormRepository[Model]) Update(updates any, options ...query.Option) error

func (*GormRepository[Model]) Upsert added in v0.2.10

func (g *GormRepository[Model]) Upsert(data *Model, conflictKeys []query.Field, updateKeys []query.Field) error

func (*GormRepository[Model]) WithContext added in v0.2.10

func (g *GormRepository[Model]) WithContext(ctx context.Context) GenericRepository[Model]

func (*GormRepository[Model]) WithTx added in v0.2.10

func (g *GormRepository[Model]) WithTx(fn func(repo GenericRepository[Model]) error) error

type ORM

type ORM interface {
	OrmName() scene.ImplName
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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