From 240027443ad8b24920dca8e86d8214800b0ed6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 26 Dec 2024 14:25:45 +0800 Subject: [PATCH] feat: fix doc-db-port --- mongo/doc-db-with-cache.go | 4 ++-- mongo/doc-db.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mongo/doc-db-with-cache.go b/mongo/doc-db-with-cache.go index 1484aa2..c176e89 100755 --- a/mongo/doc-db-with-cache.go +++ b/mongo/doc-db-with-cache.go @@ -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) } diff --git a/mongo/doc-db.go b/mongo/doc-db.go index 73fbd07..95c4c6b 100755 --- a/mongo/doc-db.go +++ b/mongo/doc-db.go @@ -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 }