Files
open-im-server/pkg/common/db/relation/meta_db.go
T

24 lines
309 B
Go
Raw Normal View History

2023-03-15 18:35:06 +08:00
package relation
import (
"context"
2023-03-16 20:35:55 +08:00
2023-03-15 18:35:06 +08:00
"gorm.io/gorm"
)
type MetaDB struct {
DB *gorm.DB
2023-03-16 20:35:55 +08:00
table any
2023-03-15 18:35:06 +08:00
}
func NewMetaDB(db *gorm.DB, table any) *MetaDB {
return &MetaDB{
DB: db,
table: table,
}
}
func (g *MetaDB) db(ctx context.Context) *gorm.DB {
return g.DB.WithContext(ctx).Model(g.table)
}