feat(database): return gorm itself
Some checks failed
Gitea Build Check / Build (push) Failing after 28s

This commit is contained in:
SoXX 2024-08-11 00:26:20 +02:00
parent 9fe2d0edc3
commit e839e7ba2a

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"embed" "embed"
"fmt" "fmt"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models" "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
migrate "github.com/rubenv/sql-migrate" migrate "github.com/rubenv/sql-migrate"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -66,3 +67,11 @@ func migrateDatabase(dbPool *gorm.DB, config models.DatabaseConfig) error {
return nil return nil
} }
func GetGorm(ctx context.Context) (*gorm.DB, error) {
if client == nil {
return nil, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
return client, nil
}