BuildShipBBuildShip
Powered by
ThomasT
BuildShip•2y ago•
14 replies
Thomas

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\"]}
${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
@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.
image.png
Jump to solution
BuildShip banner
BuildShipJoin
Join founders, builders, devs using Low-code / No-code to create backend, APIs, scheduled Jobs, automation, AI workflows
7,971Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How to construct Firebase document array of document references?
Karol GostKKarol Gost / ❓・buildship-help
15mo ago
GPT array to firebase document not working
!CarlYouKilledIt!!CarlYouKilledIt / ❓・buildship-help
2y ago
Is there a way to write a Firebase Doc Reference instead of a String?
NickyDLTNNickyDLT / ❓・buildship-help
2y ago
Firestore node - Edit Document - From array to map
AntoineAAntoine / ❓・buildship-help
4mo ago