mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
db
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package relation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MetaDB struct {
|
||||
DB *gorm.DB
|
||||
table interface{}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user