fixed upsert
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
ri "github.com/tech/sendico/pkg/db/repository/index"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -81,7 +82,11 @@ func (p *Payouts) Upsert(ctx context.Context, record *model.CardPayout) error {
|
||||
return merrors.InvalidArgument("operation ref is required", "operation_ref")
|
||||
}
|
||||
|
||||
return p.repository.Insert(ctx, record, repository.Filter(payoutIdemField, record.IdempotencyKey))
|
||||
if record.ID == bson.NilObjectID {
|
||||
return p.repository.Insert(ctx, record, nil)
|
||||
}
|
||||
|
||||
return p.repository.Update(ctx, record)
|
||||
}
|
||||
|
||||
var _ storage.PayoutsStore = (*Payouts)(nil)
|
||||
|
||||
Reference in New Issue
Block a user