Gustavo Rodrigues
Gustavo Rodrigues

Reputation: 61

[MongoDB]: Add new value to array

i'am trying a add new value to array inside object, this way:

await database.models.updateMany( { <queue> }, { $push: { object: { array: 'Hello, World!' }}});

but, thats delete the array inside the object instead of add new value

Upvotes: 1

Views: 46

Answers (1)

dege
dege

Reputation: 2949

Welcome to SO,

you should be using

await database.models.updateMany( { <queue> }, { $push: { 'object.array': 'Hello, World!' }});

Upvotes: 1

Related Questions