Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mongodb

upsert

This error happens when I tried to update upsert item:

Updating the path 'x' would create a conflict at 'x' 
like image 478
zored Avatar asked Jun 20 '18 12:06

zored


2 Answers

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

like image 62
zored Avatar answered Sep 20 '22 19:09

zored


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

like image 42
saintlyzero Avatar answered Sep 20 '22 19:09

saintlyzero