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 !
1 ACCEPTED SOLUTION

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.
1 REPLY
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.