JCS-pub/coordinator/internal/db/pub_shards.go

25 lines
542 B
Go

package db
import jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
type PubShardsDB struct {
*DB
}
func (db *DB) PubShards() *PubShardsDB {
return &PubShardsDB{DB: db}
}
func (*PubShardsDB) Get(ctx SQLContext, publicShardStoreID jcstypes.PubShardsID) (*jcstypes.PubShards, error) {
var cfg jcstypes.PubShards
if err := ctx.First(&cfg, publicShardStoreID).Error; err != nil {
return nil, err
}
return &cfg, nil
}
func (*PubShardsDB) Create(ctx SQLContext, cfg jcstypes.PubShards) error {
return ctx.Create(&cfg).Error
}