Firebase Document Reference Datatype Create/Update Issue

Describe the issue/error/question

Hi Team, I’ve a very common use case in Firebase where we want to link a collection with a different collection using the Document Reference datatype, or as an example if we have two Firebase Collections i.e.“transactions” and “users”, so if we want to link a transaction with a particular user, we need to tag the user in transaction collection record.

I believe this is one of the core functionality that is required for most of the Firebase/Firestore database. I was using Set to create the variables like String, Boolean but I’m stuck here to tag or associate the user since the Doc Ref datatype is not supported by n8n Set.

I thought of some custom logic implementation but the catch here since the Set doesn’t support Document Reference as a data type so Firebase Update Node will not consider that variable. Hence, requesting you to kindly add this data type as well.

Apart from that n8n does a really great job, it literally saved tons of hours in building with no-code. Thank you team for the wonderful product.

Information on your n8n setup

  • n8n version: 0.214 (Latest)
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Hi @ridingdfuture, welcome to the community and thanks so much for your feedback. How are you accessing Firebase right now? I assume via a HTTP request node? Would you mind sharing your workflow here?

Hey @Niklas_Hatje, I’m accessing Firestore here using the OOTB node, the problem here is quite simple like I want to link the User ID with other Firestore collections. Hence, in order to achieve the same, Firestore links the records on the basis of the “Document Reference” datatype but here in the Set Payload only String, Boolean and Number is supported.

{
“meta”: {
“instanceId”: “9e5c7f46092048423d9975f79fff4d99dd5a79cf2461076fad356837865f2909”
},
“nodes”: [],
“connections”: {}
}

Thanks for the additional context. n8n is mostly working with JSONs as data type, which only supports strings, booleans and numbers. Additionally, the n8n nodes call the API of the respective service. API calls are also using JSONs to pass data. So I assume that the firestore node should be able to handle primitive data types.

Unfortunately, I don’t know Firebase enough to know how to pass the Document Reference via the rest API. Based on a quick online research it seems like you would just pass the path to the location as string instead. But maybe someone else is more knowledgeable with the Firebase API.

Nevermind, Thank you @Niklas_Hatje for your consideration here. I’ve figured out the solution using the custom HTTP node.

People for looking for similar solution can refer to the below link for Firebase API’s CRUD operations:
Google Firestore REST API examples - Jean Snyman

2 Likes

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