database: set Handle direcetly during initialization (#7699)

This commit is contained in:
Joe Chen
2024-03-20 19:02:57 -04:00
committed by GitHub
parent dd49412edd
commit 8d2386b4db
3 changed files with 7 additions and 12 deletions

View File

@@ -128,6 +128,7 @@ func NewConnection(w logger.Writer) (*gorm.DB, error) {
TwoFactors = &twoFactorsStore{DB: db}
Users = NewUsersStore(db)
Handle = &DB{db: db}
return db, nil
}
@@ -148,11 +149,6 @@ type DB struct {
// single-thread process).
var Handle *DB
// SetHandle updates the global database handle with the given connection.
func SetHandle(db *gorm.DB) {
Handle = &DB{db: db}
}
func (db *DB) AccessTokens() *AccessTokensStore {
return newAccessTokensStore(db.db)
}