Skip to content

Commit

Permalink
bulk options
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 18, 2023
1 parent f79a32f commit 97216cc
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (m *Migration) fetchAndUpdateBatch() bool {

updateOp := mongo.NewUpdateOneModel()
updateOp.SetFilter(bson.M{"_id": datumID, "modifiedTime": dDataResult["modifiedTime"]})
updateOp.SetUpdate(datumUpdates)
updateOp.SetUpdate(bson.M{"$set": datumUpdates})
m.updates = append(m.updates, updateOp)
m.lastUpdatedId = datumID
}
Expand Down Expand Up @@ -432,9 +432,11 @@ func (m *Migration) writeBatchUpdates() (int, error) {
log.Println("dry run so not applying changes")
continue
}
bulkOption := options.BulkWriteOptions{}
bulkOption.SetOrdered(true)

if deviceC := m.getDataCollection(); deviceC != nil {
results, err := deviceC.BulkWrite(m.ctx, batch)
results, err := deviceC.BulkWrite(m.ctx, batch, &bulkOption)
if err != nil {
log.Printf("error writing batch updates %v", err)
return updateCount, err
Expand Down

0 comments on commit 97216cc

Please sign in to comment.