2020-05-26 16:46:16 +02:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jinzhu/gorm"
|
2023-04-28 16:28:13 +02:00
|
|
|
|
2023-02-27 22:36:43 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2020-05-26 16:46:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type View struct {
|
2024-01-04 17:12:20 +01:00
|
|
|
Db *gorm.DB
|
2020-05-26 16:46:16 +02:00
|
|
|
}
|
|
|
|
|
2023-02-27 22:36:43 +01:00
|
|
|
func StartView(sqlClient *database.DB) (*View, error) {
|
2023-08-22 12:49:22 +02:00
|
|
|
gorm, err := gorm.Open("postgres", sqlClient.DB)
|
2020-05-26 16:46:16 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &View{
|
2024-01-04 17:12:20 +01:00
|
|
|
Db: gorm,
|
2020-05-26 16:46:16 +02:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) Health() (err error) {
|
|
|
|
return v.Db.DB().Ping()
|
|
|
|
}
|