Documentation
¶
Index ¶
- Constants
- func GormDialectorMySql(ds datasource.MysqlDataSource) gorm.Dialector
- func GormDialectorSqlite(ds datasource.SqliteDataSource) gorm.Dialector
- type GenericRepository
- type Gorm
- type GormRepository
- func (g *GormRepository[Model]) Count(options ...query.Option) (count int64, err error)
- func (g *GormRepository[Model]) Create(data *Model) error
- func (g *GormRepository[Model]) Delete(options ...query.Option) error
- func (g *GormRepository[Model]) FindFirst(options ...query.Option) (data Model, found bool, err error)
- func (g *GormRepository[Model]) List(offset, limit int64, options ...query.Option) (model.PaginationResult[Model], error)
- func (g *GormRepository[Model]) Setup() error
- func (g *GormRepository[Model]) Update(updates any, options ...query.Option) error
- func (g *GormRepository[Model]) Upsert(data *Model, conflictKeys []query.Field, updateKeys []query.Field) error
- func (g *GormRepository[Model]) WithContext(ctx context.Context) GenericRepository[Model]
- func (g *GormRepository[Model]) WithTx(fn func(repo GenericRepository[Model]) error) error
- type ORM
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 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]) 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
Click to show internal directories.
Click to hide internal directories.