Documentation ¶
Overview ¶
Package db code
Index ¶
- Variables
- func New(cfg Config) (*gorm.DB, func())
- func Open(conf Config) (*gorm.DB, func())
- func RegisterCallback(db *gorm.DB)
- func Trace(ctx context.Context, db *gorm.DB) *gorm.DB
- type CUDTime
- type Config
- type DateTime
- type Entity
- type Repository
- func (d *Repository) Create(ctx context.Context, entity interface{}) error
- func (d *Repository) CreateTx(ctx context.Context, tx *gorm.DB, entity interface{}) error
- func (d *Repository) Delete(ctx context.Context, entity interface{}, where ...interface{}) error
- func (d *Repository) DeleteTx(ctx context.Context, tx *gorm.DB, entity interface{}, where ...interface{}) error
- func (d *Repository) Find(ctx context.Context, tx *gorm.DB, entity interface{}, out interface{}, ...) (interface{}, error)
- func (d *Repository) FindTx(ctx context.Context, tx *gorm.DB, entity interface{}, out interface{}, ...) (interface{}, error)
- func (d *Repository) Save(ctx context.Context, entity interface{}) error
- func (d *Repository) SaveTx(ctx context.Context, tx *gorm.DB, entity interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var CreatedFiledName = "created_time"
View Source
var DateTimeFormat = "2006-01-02 15:04:05"
View Source
var DeletedFiledName = "deleted_time"
View Source
var UpdatedFiledName = "updated_time"
Functions ¶
func RegisterCallback ¶
Types ¶
type Config ¶
type Config struct { Dsn string `yaml:"dsn"` MaxIdle int `yaml:"maxIdle"` MaxOpen int `yaml:"maxOpen"` MaxLifetime int `yaml:"maxLifetime"` LogMode bool `yaml:"logMode"` }
Config the db config
type DateTime ¶
func (DateTime) MarshalJSON ¶
type Repository ¶
func (*Repository) Create ¶
func (d *Repository) Create(ctx context.Context, entity interface{}) error
func (*Repository) Delete ¶
func (d *Repository) Delete(ctx context.Context, entity interface{}, where ...interface{}) error
Click to show internal directories.
Click to hide internal directories.