Using PDI Kettle MongoDB Output, I am trying to update a mongodb document, by querying the _id (ObjectId) field. If i pass the _id variable as String to the MongoDB Output step, the final query that gets created looks like
Modifier update query:
{
"_id" : "<string val>"
}
which might get transformed finally to something like
Modifier update query:
{
"_id" : "579c18b47f34b4330f85a981"
}
This might be causing the query not finding the document and update fails with error " No fields to update have been specified for modifier update operation! "
Is there any way i can specify the query as below ?
{"_id" : ObjectId(579c18b47f34b4330f85a981)}
Or am i seeing the error because of some other reason ?
Please find the screenshot of the "mongo document fields" tab.

First, you can use a "Javascript" step to transform the "_id" value in JSON format:
_id = '{ "$oid": "' + _id + '" }'
Then in the last row of "MongoDB output" step you should set the JSON attribute to Y.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With