Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] JSON format in tMongoDBOutput

Hi,
I was looking at this document.
https://help.talend.com/search/all?query=tMongoDBOutput&content-lang=en
I am not able to understand how exactly to use data node and query node here. 
Also, the tMongoDBOutput component requires the schema to be same as input schema.
I have the input coming from a sql schema as:
 Name, DOB, class, subject1_marks, subject2_marks,subject3_marks, average_marks
I want to frame a json in my mongoDB like:
{
 _id:{ name:"abc", DOB:"26-01-1947"},
subjects:
}
Also i want to perform upsert operations where i can update marks for specific subjects and add additional fields like 
{
 _id:{ name:"abc", DOB:"26-01-1947"},
subjects:
}
How to do this?
I see upsert option but am not able to use it. Also how to use properties of mongo like $push and $set here.

Thanks!
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi
The data node and the query node have to be defined in the json tree, the data node defines the data will be updated or inserted, the query node defines the query condition. In the below example, the id element is defined under the query node, it will compare the input id value with existing ids in target database, if id already exists, then update the data, otherwise, insert a new data.
0683p000009MBhw.png
0683p000009MBi1.png
Best regards
Shong

View solution in original post

1 Reply
Anonymous
Not applicable
Author

Hi
The data node and the query node have to be defined in the json tree, the data node defines the data will be updated or inserted, the query node defines the query condition. In the below example, the id element is defined under the query node, it will compare the input id value with existing ids in target database, if id already exists, then update the data, otherwise, insert a new data.
0683p000009MBhw.png
0683p000009MBi1.png
Best regards
Shong