Documentation
¶
Index ¶
- Variables
- func BindContext(ctx context.Context, db *gorm.DB) (newCtx context.Context)
- func FromContext(ctx context.Context) (db *gorm.DB, err error)
- type Creator
- type Fetcher
- type Model
- type NamedTable
- type Operator
- func (o *Operator) Create(ctx context.Context, i NamedTable) error
- func (o *Operator) CreateAll(ctx context.Context, i interface{}) error
- func (o *Operator) GetByCondition(ctx context.Context, i, cond interface{}, args ...interface{}) error
- func (o *Operator) GetByID(ctx context.Context, i NamedTable, id uint64) error
- func (o *Operator) GetByMultiID(ctx context.Context, i interface{}, ids []uint64) error
- func (o *Operator) Remove(ctx context.Context, i NamedTable) error
- func (o *Operator) RemoveAll(ctx context.Context, i NamedTable, cond ...interface{}) error
- func (o *Operator) Save(ctx context.Context, i NamedTable, selected ...string) error
- func (o *Operator) Updates(ctx context.Context, i NamedTable, values map[string]interface{}) error
- func (o *Operator) UpdatesAll(ctx context.Context, i NamedTable, values map[string]interface{}, ...) error
- type Remover
- type TimeFormat
- type Updater
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDBNotFound warnings gorm.DB not in context. ErrDBNotFound = fmt.Errorf("gorm.DB not in context") )
Functions ¶
func BindContext ¶
BindContext binds *gorm.DB
Types ¶
type Creator ¶ added in v0.3.0
type Creator interface { Create(ctx context.Context, i NamedTable) error CreateAll(ctx context.Context, i interface{}) error }
Creator interface.
type Fetcher ¶ added in v0.3.0
type Fetcher interface { GetByID(ctx context.Context, i NamedTable, id uint64) error GetByMultiID(ctx context.Context, i interface{}, ids []uint64) error GetByCondition(ctx context.Context, i, cond interface{}, args ...interface{}) error }
Fetcher interface.
type Model ¶
type Model struct { ID uint64 `json:"id" gorm:"primaryKey"` CreatedAt TimeFormat `json:"createdAt" gorm:"autoCreateTime;type:time"` UpdatedAt TimeFormat `json:"updatedAt" gorm:"autoUpdateTime;type:time"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` }
Model for gorm
type NamedTable ¶ added in v0.2.0
NamedTable for name and PK.
type Operator ¶ added in v0.2.0
type Operator struct{}
Operator collections.
func (*Operator) Create ¶ added in v0.2.0
func (o *Operator) Create(ctx context.Context, i NamedTable) error
Create item.
func (*Operator) GetByCondition ¶ added in v0.2.0
func (o *Operator) GetByCondition(ctx context.Context, i, cond interface{}, args ...interface{}) error
GetByCondition query items by conditions.
func (*Operator) GetByMultiID ¶ added in v0.2.0
GetByMultiID query items by id.
func (*Operator) Remove ¶ added in v0.2.0
func (o *Operator) Remove(ctx context.Context, i NamedTable) error
Remove item.
func (*Operator) RemoveAll ¶ added in v0.2.0
func (o *Operator) RemoveAll(ctx context.Context, i NamedTable, cond ...interface{}) error
RemoveAll items.
func (*Operator) UpdatesAll ¶ added in v0.2.0
func (o *Operator) UpdatesAll(ctx context.Context, i NamedTable, values map[string]interface{}, cond ...interface{}) error
UpdatesAll items.
type Remover ¶ added in v0.3.0
type Remover interface { Remove(ctx context.Context, i NamedTable) error RemoveAll(ctx context.Context, i NamedTable, cond ...interface{}) error }
Remover interface.
type TimeFormat ¶
TimeFormat with json/db outputs
func (*TimeFormat) FromTime ¶
func (tf *TimeFormat) FromTime(t time.Time)
func (TimeFormat) MarshalJSON ¶
func (tf TimeFormat) MarshalJSON() ([]byte, error)
MarshalJSON for json.Marshaler.
func (TimeFormat) Time ¶
func (tf TimeFormat) Time() time.Time
type Updater ¶ added in v0.3.0
type Updater interface { Save(ctx context.Context, i NamedTable, selected ...string) error Updates(ctx context.Context, i NamedTable, values map[string]interface{}) error UpdatesAll(ctx context.Context, i NamedTable, values map[string]interface{}, cond ...interface{}) error }
Updater interface.
Click to show internal directories.
Click to hide internal directories.