Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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 !
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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

3 Replies
Anonymous
Not applicable
Author

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.
kanuparthy
Contributor
Contributor

Can you provide example
maurick
Contributor
Contributor

I have the same issue to solve. Is someone has found the solution since the last 4 years? 🙂