Skip to content

Commit 85c2167

Browse files
committed
fix(api): support standalone MongoDB contacts
Contact batch inserts used transactions, which standalone MongoDB rejects. Insert the batch directly so non-replica deployments work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 80fa4141-33c6-474f-939a-f1a637639f96
1 parent 583397f commit 85c2167

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

‎api/pkg/repositories/mongo_contact_repository.go‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,7 @@ func (repository *mongoContactRepository) Store(ctx context.Context, contacts []
5050
documents[index] = contact
5151
}
5252

53-
session, err := repository.collection.Database().Client().StartSession()
54-
if err != nil {
55-
return repository.tracer.WrapErrorSpan(span, stacktrace.Propagatef(err, "cannot start transaction to store [%d] contacts", len(contacts)))
56-
}
57-
defer session.EndSession(ctx)
58-
59-
_, err = session.WithTransaction(ctx, func(transactionCtx context.Context) (any, error) {
60-
return repository.collection.InsertMany(transactionCtx, documents)
61-
})
62-
if err != nil {
53+
if _, err := repository.collection.InsertMany(ctx, documents); err != nil {
6354
return repository.tracer.WrapErrorSpan(span, stacktrace.Propagatef(err, "cannot store [%d] contacts", len(contacts)))
6455
}
6556

0 commit comments

Comments
 (0)