Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { io.Closer // Create creates record. Create(obj any) error // Update updates record by given conditions. Update(obj any, where ...any) error // Updates update attributes, values can be map/struct(select all fields include empty value fields). Updates(obj, values any, where ...any) error // UpdateSingle updates record with single column value. UpdateSingle(obj any, col string, value any, where ...any) error // Delete deletes record by given conditions. Delete(obj any, where ...any) error // Get gets record that match given conditions. Get(out any, where ...any) error // Find finds records that match given conditions. Find(out any, where ...any) error // FindForPaging finds records that match given conditions with offset and limit. FindForPaging(out any, offset, limit int, order string, query string, where ...any) error // Count returns how many records for a model based on given query conditions. Count(model any, query string, where ...any) (count int64, err error) // Exist checks record if exist by given conditions. Exist(out any, where ...any) (bool, error) // Transaction does some db operators in transaction. Transaction(fc func(tx DB) error) error // ExecRaw executes raw sql. ExecRaw(out any, query string, args ...any) error // RawDB returns raw gorm db. RawDB() *gorm.DB // Migrator returns data migrator. Migrator() gorm.Migrator }
DB represents a db wrapper based on gorm. Support: sqlit/mysql/postgres.
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
Migration represents migration information include table and init records.
func (*Migration) AddInitRecord ¶
AddInitRecord adds init record.
Click to show internal directories.
Click to hide internal directories.