Please tell me about how mongoose uses updateMany to update in batches.

Schema:

the update I want to implement is to store the same carId, for the stopName in the stops array. How should I implement such batch updates in mongoose? Common Update on the Internet is for a single field, did not encounter such a case, please friends can give a sample code, thank you!

I"m afraid people think it"s too roundabout. To put it simply, as defined by Schema, there is now an array that stores a lot of stopName,. I want to give them the same value of carid. How should I update them in batches with mongoose"s Update?


it turns out that I'm thinking too much, but it's not that complicated! [crying manually,]

Menu