/
taxes.go
32 lines (26 loc) · 1.02 KB
/
taxes.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 db
import (
"context"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"github.com/nam-truong-le/lambda-utils-go/v4/pkg/aws/secretsmanager"
"github.com/nam-truong-le/lambda-utils-go/v4/pkg/mongodb"
)
const colTaxes = "taxes"
func CollectionTaxes(ctx context.Context) (*mongo.Collection, error) {
database, err := secretsmanager.GetParameter(ctx, "/mongo/database")
if err != nil {
return nil, err
}
return mongodb.Collection(ctx, database, colTaxes)
}
type Tax struct {
ID primitive.ObjectID `bson:"_id" json:"id"`
WPID int `bson:"id" json:"wpId"`
Rate string `bson:"rate" json:"rate"`
Name string `bson:"name" json:"name"`
TaxClass string `bson:"class" json:"taxClass"` // it's ok to have different names here because we don't provide PATCH request for this entity.
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
}