/
index.go
32 lines (26 loc) · 943 Bytes
/
index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package repository
import (
"errors"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/ricardojonathanromero/lambda-serverless-example/api-gateway-example/todo-delete/internal/port"
"github.com/sirupsen/logrus"
"go.mongodb.org/mongo-driver/mongo"
"time"
)
const timeoutIn = 10 * time.Second
var (
log = logrus.New()
DocumentNotDeleted = errors.New("document could not be deleted")
)
// collection returns mongodb collection/*
func (repo *mongoRepo) collection() *mongo.Collection {
return repo.conn.Database(repo.db).Collection(repo.col)
}
// NewMongo constructor for repository package/*
func NewMongo(conn *mongo.Client, db string, col string) port.IRepository {
return &mongoRepo{conn: conn, db: db, col: col}
}
// NewDynamo constructor for repository package/*
func NewDynamo(client *dynamodb.Client, tableName string) port.IRepository {
return &dynamoRepo{client: client, tableName: tableName}
}