Can I update two documents with different _id using update_many?

30 Views Asked by At

I want to update two documents by _id using the update_many function. Is it possible to do this? If so, how should I implement it?

I tried to use AI to implement this, but it didn't work. Here is the code I managed to write:

database.update_many(
    filter={"_id": {"$inc": ["Shares", "Crypto"]}},
        update=[
            UpdateMany({"$set": share_data}),
            UpdateMany({"$set": crypto_data})
        ],
    upsert=True
)
0

There are 0 best solutions below