Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearRegisteredModels ¶ added in v2.2.0
func ClearRegisteredModels()
ClearRegisteredModels unregister all models.
func GetConnection ¶
GetConnection returns the global database connection pool. Creates a new connection pool if no connection is available.
The connections will be closed automatically on server shutdown so you don't need to call "Close()" when you're done with the database.
func GetRegisteredModels ¶ added in v2.2.0
func GetRegisteredModels() []interface{}
GetRegisteredModels get the registered models. The returned slice is a copy of the original, so it cannot be modified.
func RegisterModel ¶
func RegisterModel(model interface{})
RegisterModel registers a model for auto-migration. When writing a model file, you should always register it in the init() function.
func init() { database.RegisterModel(&MyModel{}) }
Types ¶
type Factory ¶ added in v2.2.0
type Factory struct {
// contains filtered or unexported fields
}
Factory an object used to generate records or seed the database.
func NewFactory ¶ added in v2.2.0
NewFactory create a new Factory. The given generator function will be used to generate records.
func (*Factory) Override ¶ added in v2.2.0
Override set an override model for generated records. Values present in the override model will replace the ones in the generated records. This function expects a struct pointer as parameter. Returns the same instance of `Factory` so this method can be chained.