# Firestore Create/Update upsert into subcollection

**URL:** <https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801>\
**Category:** Questions\
**Tags:** firestore\
**Created:** [November 1, 2021, 11:12am UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801 "2021-11-01T11:12:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![benneic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/benneic/32/7788_2.png) [@benneic](https://community.n8n.io/u/benneic)\
**Post date:** [November 1, 2021, 11:12am UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/1 "2021-11-01T11:12:40Z")

</div>

I’m new to n8n… what am I doing wrong here? Is this a bug or not supported?

When my workflow executes a document is created in my subcollection (users/{user-id}/videoAskQuestions) with an id of **undefined** even though it appears as though it should work see screenshots:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/b/bd7b49759fad168a916f348993afd9e7c72b48c2.png)

this is in Firestore:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/a/a3e728bdd82b028e13f0778711714e5ee9bfa0b9.png)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 1, 2021, 1:27pm UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/3 "2021-11-01T13:27:09Z")

</div>

Hi @benneic, welcome to the community! I hope you’re having a good day thus far?

In the update key field you’d define the name of the field which holds the id of the document to update (or create). So in your example, n8n would use a field with a name of `02266c88...` which does not exist (and thus would have an `undefined` value).

Instead you’d need the name of the field with the respective value:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/3/3e96a52120eeeabd3903c9660bf6afb6c0864ebd.png)

> **Example workflow**
>

I hope this makes sense and helps! Let me know if you still run into any trouble afterwards.

---

<div class="post-metadata">

**Author:** ![benneic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/benneic/32/7788_2.png) [@benneic](https://community.n8n.io/u/benneic)\
**Post date:** [November 2, 2021, 12:38am UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/4 "2021-11-02T00:38:33Z")

</div>

Awesome, that works now! And obvious what \*Update **Key** \* means now that I’ve had a sleep and come back to it…

Update Key = “Provide the key that corresponds to the value in the input used to identify the document for create and update operations.”

Cheers!

---

<div class="post-metadata">

**Author:** ![roon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/roon/32/32210_2.png) [@roon](https://community.n8n.io/u/roon)\
**Post date:** [November 17, 2023, 4:25am UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/5 "2023-11-17T04:25:10Z")

</div>

What if I want to update the value of a document’s key value to something dynamic that is not held by that key? What is the format that n8n expression expects?

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 21, 2023, 2:33pm UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/6 "2023-11-21T14:33:18Z")

</div>

Hi @roon, welcome to the community! This is a rather old thread that has been marked as solved two years ago and n8n has changed a lot since.

Perhaps you can open a new forum topic, and provide all details required to understand the problem you are looking to solve? In particular, your current document structure, the JSON data you have in n8n, and the new document structure you’d like to see after running your Firestore node.

For general information on expressions you can also check out [our docs](https://docs.n8n.io/code/expressions/).

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 28, 2023, 2:33pm UTC](https://community.n8n.io/t/firestore-create-update-upsert-into-subcollection/8801/7 "2023-11-28T14:33:58Z")

</div>

Closed on November 28, 2023, 2:33pm UTC

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