firebase map instead of array saved
Hello everyone,
I'm facing an issue with a node in my BuildShip workflow that's supposed to save an array of strings to a Firestore document. Instead of saving the array, it ends up saving a map. Here's a breakdown of the situation:
Context:
I'm using the @buildship/create-firestore-document node to create or update a document in a Firestore collection.
The document should contain an array field named searchTermProxies.
Current Configuration:
[
{
"_libRef": {
"integrity": "v3:c86b19093b8beaf454a6d4cc9f2f577a",
"libNodeRefId": "@buildship/create-firestore-document",
"isDirty": false,
"libType": "public",
"src": "https://storage.googleapis.com/buildship-app-us-central1/publicLib/nodes/@buildship/create-firestore-document/1.3.1/build.cjs",
"version": "1.3.1"
},
"id": "db65dd0f-6b7d-4aeb-8d14-efb43f7ba4c0",
"label": "Create Document",
"type": "script",
"onFail": null,
"values": {
"projectId": {
"type": "text",
"expression": "projectEnv["firebase project id"]"
},
"merge": true,
"id": {
"expression": "${ctx[\"root\"][\"request\"][\"body\"][\"listingId\"]}
",
"hasErrors": false,
"type": "javascript"
},
"data": {
"expression": "{\n "searchTermProxies": Array.isArray(ctx["root"]["10f889b1-0ecf-44e6-a639-41496d1378d0"]["98713c80-5eba-455f-af1c-25ab600c942b"]["d7eed1c8-814b-4601-a7ab-c9464bfb0433"]) ? ctx["root"]["10f889b1-0ecf-44e6-a639-41496d1378d0"]["98713c80-5eba-455f-af1c-25ab600c942b"]["d7eed1c8-814b-4601-a7ab-c9464bfb0433"] : []\n}",
"type": "javascript",
"hasErrors": false
},
"collectionName": "listings"
}
}
]
Any guidance or help to resolve this issue would be greatly appreciated. Thanks in advance!Solution:Jump to solution
@Thomas Use the "Add Object to Firestore Array" node after you create document to update the specific field to type array. It should then update the field type to array, as the current firestore create doc converts the data to the preferred firestore type. This should solve your issue.
11 Replies
BuildShip AI Support - Crafting Solution, (Avg response time: ~2 minutes 🙂)
Sorry, there was an error processing your request. Please try again in ~1 minute
Hi @Thomas Can you share the sample data format which you are trying to create doc.
To share the sample data format for creating a document in BuildShip, please refer to the documentation for the specific node or workflow you are using. If you need more detailed information or examples, you can submit your query via the in-app support button for personalized assistance.
For general guidance on data formats and nodes, you might find the following documentation useful: BuildShip Documentation.
If you have any further questions, please feel free to reach out.
sure, this is the array input:
[
"proxy_1"
]
This my firebase structure
Sorry, there was an error processing your request. Please try again in ~1 minute
For assistance with Firebase and its integration with BuildShip, please submit your query via the in-app support button. This will allow our support team to provide you with the most accurate and detailed guidance based on your specific needs.
This is what I get
Sure, I'd be happy to assist! Could you please provide more details about the issue you're encountering? If it's related to a specific node or functionality, mentioning that would help me provide a more targeted response. If you need immediate assistance, you can also submit your query via the in-app support button.
Solution
@Thomas Use the "Add Object to Firestore Array" node after you create document to update the specific field to type array. It should then update the field type to array, as the current firestore create doc converts the data to the preferred firestore type. This should solve your issue.
omg! amazing, 1000 thanks!