How to properly use the mongo update operator?

kaymankayman Member Posts: 662 Unicorn
edited November 2018 in Help

I wanted to use the mongo update operator for some simple process, but it keeps stating there is something wrong with the JSON format I provide, even in the simplest format possible. My assumption is therefore that I must have misunderstood how it works, but there are no examples available.

 

This is an extreme simple example that fails, can someone tell me how I need to use it properly?

 

<?xml version="1.0" encoding="UTF-8"?><process version="8.1.003">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="8.1.003" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document (2)" width="90" x="179" y="136">
<parameter key="text" value="{&quot;key&quot; : &quot;value&quot;}"/>
</operator>
<operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document (3)" width="90" x="179" y="34">
<parameter key="text" value="{&quot;_id&quot; : &quot;dummy&quot;}"/>
</operator>
<operator activated="true" class="nosql:mongodb_document_updater" compatibility="7.6.000" expanded="true" height="82" name="Update MongoDB (3)" width="90" x="380" y="34">
<parameter key="mongodb_instance" value="my_mongo_db"/>
<parameter key="collection" value="my_collection"/>
<parameter key="update_individual_fields" value="false"/>
<parameter key="insert_unmatched_documents_(upsert)" value="true"/>
</operator>
<connect from_op="Create Document (2)" from_port="output" to_op="Update MongoDB (3)" to_port="update"/>
<connect from_op="Create Document (3)" from_port="output" to_op="Update MongoDB (3)" to_port="criteria"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
</operator>
</process>

Note that I have no problem using the other operators, in general I use the execute mongoDB command to perform updates but I'm puzzled with what goes wrong with this one.

Answers

  • kaymankayman Member Posts: 662 Unicorn

    Seems I need to use explicit statements like $set to make it work, so it may be more of a semantic statement.

    Would be nice anyway to learn a bit more about the options / limitations of the mongo operators to avoid trial and error workflows.

Sign In or Register to comment.