How to update many entries efficiently

Hi all, newish to mongo.

Im fetching a bunch of strings (350K+) and initially populating the collection with a schema with just the name property:
name: String,
data: [{ fetch1: someRandomObjectType, fetch2: someRandomObjectType }], // <— initially empty

Afterwards, for each record I am using the name to fetch the additional data in chunks of about 2.5k. This additional data can be fetched from different sources, hence fetch1/fetch2 etc.
So once I get the data I would like to update the records where name === result of fetch1(name).

What would be the best way to do this? Do I have to just loop over my 2.5 results and updateOne({ name: name}) or is there some clever filter I can do with updateMany?

The names are of course unique but I cant use them as ObjectId since the strings are too long.

Hi @Tomasz_Jakubek ,

Welcome to The MongoDB Community Forums! :wave:

To understand your use case better, could you please provide below details?

  • MongoDB Version
  • Some sample documents
  • Expected Output
  • Your workflow using sample documents and expected output
  • What have you tried?