From 97216cc095e9ae7485929b2a82f043b2a35a1975 Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 18 Dec 2023 22:38:18 +1300 Subject: [PATCH] bulk options --- .../20231128_jellyfish_migration.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go index fc29cfd57..c4b44da3b 100644 --- a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go +++ b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go @@ -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 } @@ -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