Updating the path 'x' would create a conflict at 'x'

This error happens when I tried to update upsert item:

Updating the path 'x' would create a conflict at 'x'

Solution 1:

Field should appear either in $set, or in $setOnInsert. Not in both.

Solution 2:

I had the same problem while performing an update query using PyMongo.
I was trying to do:


> db.people.update( {'name':'lmn'}, { $inc : { 'key1' : 2 }, $set: { 'key1' : 5 }})

Notice that here I'm trying to update the value of key1 from two MongoDB Update Operators.

This basically happens when you try to update the value of a same key with more than one MongoDB Update Operators within the same query.

You can find a list of Update Operators over here