feat(database): return gorm itself
Some checks failed
Gitea Build Check / Build (push) Failing after 28s
Some checks failed
Gitea Build Check / Build (push) Failing after 28s
This commit is contained in:
parent
9fe2d0edc3
commit
e839e7ba2a
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
|
||||
migrate "github.com/rubenv/sql-migrate"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -66,3 +67,11 @@ func migrateDatabase(dbPool *gorm.DB, config models.DatabaseConfig) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetGorm(ctx context.Context) (*gorm.DB, error) {
|
||||
if client == nil {
|
||||
return nil, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user