Documentation ¶
Index ¶
- func CreateCustomIndices(tx *gorm.DB, model interface{}, tableName string) error
- func CreateForeignKeyConstraintsSelf(tx *gorm.DB, model interface{}, tableName string) error
- func DeleteAllData(appType types.AppType)
- func Finalize()
- func GetDB(host ...Host) *gorm.DB
- func Initialize(extraHosts ...Host)
- func NewDB(args string, _ Host) (db *gorm.DB, err error)
- func Reset(db *gorm.DB, appType types.AppType, force bool)
- func Transaction(db *gorm.DB, body func(*gorm.DB) error) (err error)
- type DBApp
- type Host
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCustomIndices ¶
CreateCustomIndices creates custom indices if model implements models.CustomIndexer.
func CreateForeignKeyConstraintsSelf ¶
CreateForeignKeyConstraintsSelf creates foreign key constraint if model implements models.ForeignKeyConstrainer.
func DeleteAllData ¶
DeleteAllData with `DELETE` since TRUNCATE runs so slow in cockroachdb This method provides same functionality as `dropAllDatabase`
func Initialize ¶
func Initialize(extraHosts ...Host)
Initialize initializes models. It only creates the connection instance, doesn't reset or migrate anything.
func NewDB ¶
NewDB configures given params in shared flow and returns an ORM DB instance with same functionalities and features. In this package, we create global DB instance with shared params. For external package, e.g: record, it connects to restored instance with different params.
Types ¶
type DBApp ¶
type DBApp interface { // Models returns the models for a given database app. Models() []interface{} // IsEmpty check if a given database is empty. IsEmpty(db *gorm.DB) bool // PreReset is executed before db is reset. PreReset(db *gorm.DB) error // PostReset is executed after db is reset. PostReset(db *gorm.DB) error }
DBApp is an interface for different database applications.