I\'m trying to build MongoDB Java findAndModify query.
The main purpose is that I would like to set _id in insert query by myself.
Here is m
The essential problem here is this:
db.collection.update(
{ "type": "group" },
{
"$set": { "mygroup": "value" }
"$setOnInsert" { "mygroup": "value" }
}
)
Which is basically what you are trying to do.
You cannot address the same field in a $set
operation as a $setOnInsert
operation.
There is a general problem in the logic that causes the error you are experiencing.