Firestore Field Names from JSON

Hey! First timer here. I’m trying to rebuild an app I had on Glide/Make over here on Firestore/N8N so forgive me but I’m new to both N8N and firestore.

I’m trying to create a document for each of my planners and for now I’m just trying to create a single field in each document. But, my basic question is how to structure the field data? I can’t find how to define the field name and value in the documentation. I’m trying to get “description” as the field name and my expression as its value.

The documentID is going nicely, but I’m struggling to understand how to then pass my columns/attributes in a way that maps to fields: data in Firestore.

For example, when I pass {{ $json.rows[‘8qfdO’] }} I end up with multiple fields whose names are all parts of by string separated by commas with “null” as each’s value.

Alternatively, when I try passing it in JSON such as “{
“description”: “{{ $json.rows[‘8qf0d’].toString().split(/[\n\r,]+/).join(’ ') }}”
}” I get it all in one field name, but again, the value is null.

Sorry, I’m 100% sure this is a basic dumby question from a newbie, but I’ve been at it for hours and can use the help. Thanks!

Please share your workflow

Information on your n8n setup

  • n8n version: 1.64.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via Google Cloud:
  • Operating system: Chrome

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I’m also running into the same issue. No matter how I structure the fields/attribues all values are null in firestore.

{
“id”: 123,
“status”: {
“message”: “Matching ingredients”,
“status”: “processingIngredients”,
“timestamp”: “October 25, 2024 at 4:38:46 PM UTC+1”
}
}

Even using an Edit Fields node results in the same issue

1 Like

I ran the same operation in Make.com and it worked. The bundles had the structure: [
{
“path”: “/planners”,
“fields”: [
{
“value”: “text blah blah blah”,
“fieldName”: “description”,
“valueType”: “stringValue”
}
],
“documentId”: “Reading”,
“input_type”: “select”,
“project_id”: “mis”
}
]

Tried restructuring that in N8N and passing like:

“fields”: [
{
“value”: “{{ $json.rows[‘8qfdO’] }}”,
“fieldName”: “description”,
“valueType”: “stringValue”
}
],

but still no dice.
image

same issue here, I’ve tried everything in the past 2 hours, nothing seems to work.

WHY do computers hate us?!? :wink:

Ok, I gave up and created a HTTP module as a workaround until this Firestore module gets fixed or better documentation.

I was trying to post into a subcollection, so my post method went to this url: https://firestore.googleapis.com/v1/projects/{projectID}/databases/(default)/documents/{rootcollection}/{{ $(‘Get Caregiver UID’).item.json._id }}/{subcollection}/

I was able to use my same predefined credential type that I had created for the Firestore module so no changes there.

Choose Send Headers and pass: Content-Type: application/json

Choose to Send Body, select JSON as the type and then Using JSON. Here was my fields (this is for an sms chat app):

{
“fields”: {
“to”: { “stringValue”: “{{ $(‘Receive SMS’).item.json.body.to }}” },
“from”: { “stringValue”: “{{ $(‘Receive SMS’).item.json.body.from }}” },
“body”: { “stringValue”: “{{ $(‘Receive SMS’).item.json.body.body }}” }
}
}

It works! Hope this helps someone else.

2 Likes

Thanks Andrew, the http request works for me as well.

The only thing I had to doublecheck is the {projectname} which actually should be the {project-id} as those can be different and google needs the id of the project in the http request.

1 Like

Much appreciated Andrew. Implemented using your method (HTTP module).

The Firebase node definitely needs updating. How can this be raised with the development team?

good point! Updating my previous with this. Thanks!

I’ve got the Firebase node working, it’s very simple and would be great if the documentation could be updated by the n8n team.

Make sure the input node has the fields you want. e.g. they would be available in an expression formatted $json.fieldname.

Then in the Firebase node enter the field name wtihout any of the typical $ based syntax. e.g. fieldname.

This doesn’t make much sense but it seems to work!

1 Like

Thanks @leeh! It took me a bit to have the time to test this but yes, that setup for the module works! Though, I agree this should be looked at. For example, it’s not intuitive at all how to mix and match input modules if I want to take part from the previous module, but maybe something else from earlier. But you certainly got this working!