Skip to content

Commit

Permalink
Correct the Upsert syntax for MongoDB overwrite (#220)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <[email protected]>
  • Loading branch information
peterbroadhurst authored May 27, 2022
1 parent c86cb21 commit b75545b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/rest/mongoreceipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ func (m *mongoReceipts) connect() (err error) {
// To account for any transitory failures writing to mongoDB, it retries adding receipt with a backoff
func (m *mongoReceipts) AddReceipt(requestID string, receipt *map[string]interface{}, overwrite bool) (err error) {
if overwrite {
query := m.collection.Find(bson.M{"_id": requestID})
return m.collection.Upsert(query, *receipt)
return m.collection.Upsert(bson.M{"_id": requestID}, *receipt)
} else {
return m.collection.Insert(*receipt)
}
Expand Down

0 comments on commit b75545b

Please sign in to comment.