2022-10-01 15:17:04 +02:00
|
|
|
package entity
|
|
|
|
|
2022-10-03 22:59:29 +02:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Set UTC as the default for created and updated timestamps.
|
|
|
|
func init() {
|
|
|
|
gorm.NowFunc = func() time.Time {
|
|
|
|
return UTC()
|
|
|
|
}
|
|
|
|
}
|
2022-10-01 15:17:04 +02:00
|
|
|
|
|
|
|
// Db returns the default *gorm.DB connection.
|
|
|
|
func Db() *gorm.DB {
|
2023-01-17 15:40:55 +01:00
|
|
|
if dbConn == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-10-01 15:17:04 +02:00
|
|
|
return dbConn.Db()
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnscopedDb returns an unscoped *gorm.DB connection
|
|
|
|
// that returns all records including deleted records.
|
|
|
|
func UnscopedDb() *gorm.DB {
|
|
|
|
return Db().Unscoped()
|
|
|
|
}
|