[resolved] Update an array in MongoDB

Highlighted
One Star

[resolved] Update an array in MongoDB

Hi,
I want to insert a new element in an array using tMongoDbOutput,
example:
"array":
and after modification it should become:
"array":
how to do this ? i guess it's related to the JSON Tree in tMongoDbOutput but i don't know how !

Accepted Solutions
One Star

Re: [resolved] Update an array in MongoDB

Hi i found the solution,
tMongoDBOutput won't work, I had to use tMongoDBRow, with this function:
"function(var){
return db.collection.update(
{query},
{$addToSet : { 'array_name': var }}
)
} ;
"
var could be a document or any other type.

View solution in original post


All Replies
One Star

Re: [resolved] Update an array in MongoDB

Hi i found the solution,
tMongoDBOutput won't work, I had to use tMongoDBRow, with this function:
"function(var){
return db.collection.update(
{query},
{$addToSet : { 'array_name': var }}
)
} ;
"
var could be a document or any other type.

View solution in original post

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now