I have a collection in MongoDB called "Users". Here, I want to update two specefic documents with different values on request. So far, I have succeded with selecting them both, but I can't seem to find a way to specefy the values. I can only give them the same value. Here is what I have so far:
db.db(DBName).collection("Users").updateMany(
{id: {$in: [1, 2]}},
{$set: {Value: "test"}}
This works fine but both of them of cause gains the value "test". Is there a way to specefy what the id: 1 gains the value "test1" and the id: 2 gains the value "test2"?
question from:
https://stackoverflow.com/questions/65847518/updatemany-with-different-values-mongodb 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…