<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic tMongoDBoutput JSON Tree - write ObjectId (a reference to a different Object) in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253247#M36649</link>
    <description>&lt;P&gt;I need to store a field as an ObjectId when writing my MongoDB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Situation:&lt;/P&gt;
&lt;P&gt;Two collections: Customer and Contract&lt;/P&gt;
&lt;P&gt;First I load Customer records, and an ID is generated by MongoDB for each of those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, I load the Contract collection using tMongoDBoutput (JSON Tree option), and I do a lookup on Customer, to read the _id (which is returned in my tMongoDBinput as a string), and then I wish to write that value into the Contract, field customer_id.&amp;nbsp; Fine but it is written as "5a106cdb72b2da36f074f2a4".&amp;nbsp; I need it to be written as &lt;STRONG&gt;ObjectId("5a106cdb72b2da36f074f2a4")&lt;/STRONG&gt;.&amp;nbsp; I've tried @class of objectId, @class id, and @type objectId and id, and it just keeps coming out as a string type.&amp;nbsp; What is the correct way to write the field as ObjectId?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't seem to find any list of valid @class and @type for the JSON Tree configuration.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 04:37:27 GMT</pubDate>
    <dc:creator>bglaplante</dc:creator>
    <dc:date>2024-11-16T04:37:27Z</dc:date>
    <item>
      <title>tMongoDBoutput JSON Tree - write ObjectId (a reference to a different Object)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253247#M36649</link>
      <description>&lt;P&gt;I need to store a field as an ObjectId when writing my MongoDB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Situation:&lt;/P&gt;
&lt;P&gt;Two collections: Customer and Contract&lt;/P&gt;
&lt;P&gt;First I load Customer records, and an ID is generated by MongoDB for each of those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, I load the Contract collection using tMongoDBoutput (JSON Tree option), and I do a lookup on Customer, to read the _id (which is returned in my tMongoDBinput as a string), and then I wish to write that value into the Contract, field customer_id.&amp;nbsp; Fine but it is written as "5a106cdb72b2da36f074f2a4".&amp;nbsp; I need it to be written as &lt;STRONG&gt;ObjectId("5a106cdb72b2da36f074f2a4")&lt;/STRONG&gt;.&amp;nbsp; I've tried @class of objectId, @class id, and @type objectId and id, and it just keeps coming out as a string type.&amp;nbsp; What is the correct way to write the field as ObjectId?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't seem to find any list of valid @class and @type for the JSON Tree configuration.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:37:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253247#M36649</guid>
      <dc:creator>bglaplante</dc:creator>
      <dc:date>2024-11-16T04:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: tMongoDBoutput JSON Tree - write ObjectId (a reference to a different Object)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253248#M36650</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;So far, we doesn't have any datatype as ObjectID.&lt;/P&gt;
&lt;P&gt;Have you tried to use tWriteJSONField component and for an &lt;SPAN class="emphasis"&gt;object&lt;/SPAN&gt; element, you need to add an attribute named &lt;SPAN class="emphasis"&gt;class&lt;/SPAN&gt; and set its static value to &lt;SPAN class="emphasis"&gt;object?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="emphasis"&gt;Here is the related component reference:&lt;A title="https://help.talend.com/reader/LNO9Tqm8svZQklRyXL8OYw/e_8p6JjSNgXjcaSyWdvlwg" href="https://help.talend.com/reader/LNO9Tqm8svZQklRyXL8OYw/e_8p6JjSNgXjcaSyWdvlwg" target="_self" rel="nofollow noopener noreferrer"&gt;https://help.talend.com/reader/LNO9Tqm8svZQklRyXL8OYw/e_8p6JjSNgXjcaSyWdvlwg&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="emphasis"&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="emphasis"&gt;Sabrina&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 09:46:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253248#M36650</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-26T09:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: tMongoDBoutput JSON Tree - write ObjectId (a reference to a different Object)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253249#M36651</link>
      <description>&lt;P&gt;My latest iteration, at your suggestion (although not exactly) is:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;tDBInput -&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tMap -&amp;gt; tSortRow -&amp;gt; tMongoDBOutput&lt;/P&gt; 
&lt;P&gt;tMongoDBInput&amp;nbsp; ^&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In the tMongoDBInput, I read the referenced data, selecting the legacyID (int) and the _id (string) - this is the contract_id&lt;/P&gt; 
&lt;P&gt;In the tMap I link my data on legacyID.&amp;nbsp; The output (2 fields) is (1) the customer to be modified, and (2) the related contract forumulated as:&lt;/P&gt; 
&lt;P&gt;new org.bson.types.ObjectId( contract._id )&amp;nbsp; ... which is set as type Object&lt;/P&gt; 
&lt;P&gt;I'm then sorting on the customer #.&lt;/P&gt; 
&lt;P&gt;The tMongoDBOutput is using the "Generate JSON Document"&lt;/P&gt; 
&lt;P&gt;The array "contracts" has a child, contractId (related to the object input field contractId) and has @class object.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Once again, the output is simply a string, not an ObjectId.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;On another angle - can this be done using tMongoDBRow as a post load update?&amp;nbsp; I have a mongoDB command line solution (to update the type), but I'm unsure how to have Talend run that for me.&amp;nbsp;&amp;nbsp; txxxsqlrow is clear, but tMongoDBRow is confusing.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 04:42:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2253249#M36651</guid>
      <dc:creator>bglaplante</dc:creator>
      <dc:date>2019-09-28T04:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: tMongoDBoutput JSON Tree - write ObjectId (a reference to a different Object)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2474197#M141088</link>
      <description>&lt;P&gt;&amp;nbsp;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case you have to use &lt;SPAN&gt;BSON objects by adding&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="syntax"&gt;__DOLLAR__&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;before the object.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Documentation:&amp;nbsp;&lt;A href="https://help.talend.com/en-US/components/8.0/mongodb/tmongodboutput-standard-properties?ver=39#anchor-2" target="_self"&gt;https://help.talend.com/en-US/components/8.0/mongodb/tmongodboutput-standard-properties?ver=39#anchor-2&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DBonill1656091925_0-1722524248360.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/170135i5BE63FE040584C73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DBonill1656091925_0-1722524248360.png" alt="DBonill1656091925_0-1722524248360.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is equivalent to:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt; {
     "organization": {
         "$oid": "63df25a1343a3278747d6398"
     }
 }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="emphasis"&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="emphasis"&gt;David&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:00:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMongoDBoutput-JSON-Tree-write-ObjectId-a-reference-to-a/m-p/2474197#M141088</guid>
      <dc:creator>DBonill1656091925</dc:creator>
      <dc:date>2024-08-01T15:00:42Z</dc:date>
    </item>
  </channel>
</rss>

