Wrong mapping - firestore

hello everyone.
I’m facing a strange issue with saving data to firestore.
Everything works well except phone number field, firestore saves phone number as number, ok, i understand the logic, but my app at the other end waiting string.


then i tried map data like this

preview output is correct. but when i use real data i got this at the end:
[
{**
““phone”: +905510768748\n}”: null,
““user_id”: rL81LCj7KxgddcPYlVTcUvp0txu1”: null,
https://firebasestorage.googleapis.com/v0/b/moka-2344b.appspot.com/o/images%2FrL81LCj7KxgddcPYlVTcUvp0txu1%2F1758262313142_2.jpg?alt=media&token=95673893-f629-4a93-a507-ce5a4b3f90e6”: null,
““telegramId”:”: null,
““imageUrls”: https://firebasestorage.googleapis.com/v0/b/moka-2344b.appspot.com/o/images%2FrL81LCj7KxgddcPYlVTcUvp0txu1%2F1758262311181_0.jpg?alt=media&token=25f201ef-3330-4fe4-8b6e-7131eed49f45”: null,
““updated_at”: 2025-09-19T06:11:53.675835+00:00”: null,
““created_at”: 2025-09-19T06:11:53.675835+00:00”: null,
““category_id”: 8”: null,
““city_id”: 10”: null,
"{\n “desc”: :double_exclamation_mark:**ПРОДАЖА 2+1 \n\n📍Анталия”: null,
““text”: Продам 2+1 квартиру в Анталии”: null,
““short_add”: false”: null
}
]

phone number comes to firestore node as string

i need to store phone number as string in firestore, could anyone help please?

Hi there, welcome @Abmitions to the community

what you can do is change the data type, if it’s a string and you want to change it to number, you can just add .toNumber() function but if it’s from number to string, use .toString()

just make sure that if you want to change string to number, that everything inside is a number, so not “+90…” but instead “90…”

hope tht helps!

3 Likes

I dont think it works like that. The firestore node automatically tries to determine the data type when it stores the document. This is super annoying as it will change any string number into a number type, meaning values leading with zeros get chopped off. The only way I have gotten around this is to prefix numbers with an underscore and then slicing it when I read the value again.

I can confirm this issue, it seems like the firestore node doesn’t respect the type, this is also causing me issues. One of the issues with this node is that it doesn’t allow you to specify key:value pairs, only the keys. If it was more setup like the set node, then we could ensure values are properly typed.

Correct. It’s in the codebase if you go look at line 88 of the below function for the firestore built in node. It tries to determine the best data type based on the value, instead of respecting the type you might have tried to set from n8n: