Replace NewClient with mongo.Connect

This commit is contained in:
Juan Calderon-Perez
2023-11-16 08:22:40 -05:00
committed by GitHub
parent 4b89c87336
commit 9190b12c2e
2 changed files with 8 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
name: Golangci Lint Check name: Golangci-Lint Check
on: on:
push: push:
@@ -32,7 +32,7 @@ jobs:
DIRECTORIES=$(find . -type d -not -path '*/\.*' | jq -R -s -c 'split("\n")[:-1]') DIRECTORIES=$(find . -type d -not -path '*/\.*' | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT
golangci-lint: lint:
needs: generate-matrix needs: generate-matrix
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

View File

@@ -53,11 +53,13 @@ func New(config ...Config) *Storage {
} }
// Set mongo options // Set mongo options
opt := options.Client() opt := options.Client().ApplyURI(dsn)
opt.ApplyURI(dsn)
// Create mongo client // Create and connect the mongo client in one step
client, err := mongo.NewClient(opt) ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
client, err := mongo.Connect(ctx, opt)
if err != nil { if err != nil {
panic(err) panic(err)
} }