# Can't $push to an array field in MongoDB

**URL:** <https://community.n8n.io/t/cant-push-to-an-array-field-in-mongodb/139104>\
**Category:** Questions\
**Tags:** mongodb\
**Created:** [June 26, 2025, 2:19pm UTC](https://community.n8n.io/t/cant-push-to-an-array-field-in-mongodb/139104 "2025-06-26T14:19:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liammaj](https://avatars.discourse-cdn.com/v4/letter/l/ecd19e/32.png) [@liammaj](https://community.n8n.io/u/liammaj)\
**Post date:** [June 26, 2025, 2:19pm UTC](https://community.n8n.io/t/cant-push-to-an-array-field-in-mongodb/139104/1 "2025-06-26T14:19:49Z")

</div>

I’m trying to update a MongoDB document by adding a new item to an array field without overwriting the existing ones.

example:  
I have a collection students and each student document contains an array of grades:  
{  
“\_id”: “666abc1234567890abcdef12”,  
“name”: “John Doe”,  
“grades”: [  
{ “subject”: “Math”, “score”: 95 }  
]  
}  
Now I want to **add a new grade** , like:  
{ “subject”: “Science”, “score”: 88 }

I thought I could use the MongoDB node (update) with:

- `Update Key`: `_id`
- `Fields`: `grades`
- `Value`:  
{  
“$push”: {  
“grades”: {  
“$each”: [  
{ “subject”: “Science”, “score”: 88 }  
]  
}  
}  
}  
But this results in Mongodb storing $push as field, like this:  
{  
“\_id”: “…”,  
“name”: “John Doe”,  
“grades”: {  
“$push”: {  
“grades”: {  
“$each”: [  
{ “subject”: “Science”, “score”: 88 }  
]  
}  
}  
}  
}

## Information n8n setup

- **n8n version:1.99.1**
- **Running n8n via Docker:**

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [September 24, 2025, 2:20pm UTC](https://community.n8n.io/t/cant-push-to-an-array-field-in-mongodb/139104/2 "2025-09-24T14:20:41Z")

</div>

Closed on September 24, 2025, 2:20pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
