feat: fix doc-db-port

This commit is contained in:
王性驊 2024-12-26 14:25:45 +08:00
parent 24e302990a
commit 240027443a
2 changed files with 4 additions and 4 deletions

View File

@ -15,8 +15,8 @@ type DocumentDBWithCache struct {
Cache cache.Cache
}
func MustDocumentDBWithCache(conf *Conf, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
documentDB, err := NewDocumentDB(conf, dbOpts...)
func MustDocumentDBWithCache(conf *Conf, collection string, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
documentDB, err := NewDocumentDB(conf, collection, dbOpts...)
if err != nil {
return nil, fmt.Errorf("failed to initialize DocumentDB: %w", err)
}

View File

@ -20,7 +20,7 @@ type DocumentDB struct {
Mon *mon.Model
}
func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error) {
func NewDocumentDB(config *Conf, collection string, opts ...mon.Option) (DocumentDBUseCase, error) {
authenticationURI := ""
if config.User != "" {
authenticationURI = fmt.Sprintf(
@ -50,7 +50,7 @@ func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error)
opts = append(opts, intOpt)
logx.Infof("[DocumentDB] Try to connect document db `%s`", printConnectUri)
client, err := mon.NewModel(connectionURI, config.Database, config.Database, opts...)
client, err := mon.NewModel(connectionURI, config.Database, collection, opts...)
if err != nil {
return nil, err
}