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