I need to update a field(score) in a document but I can’t use number variables. Instead of updating a single field, if I update as a whole document( both name and score), it works. I don’t want to upload the score as a string using ToString(). Because if I upload the score as a string, then I can’t get the leaderboard to be in descending order since the score is a string now. So I want to update the field(score) as a number variable. How to do it?
But this stores the value as a string in the firestore document. And because of this I can’t query the scores in descending order to display the leaderboard.
I want it to be stored as a number.
I don’t know much about firestore or firebase or other stuff, but even if it saves as “15”, it can display that text and change it to 15. You can convert a text into a number using ToNumber(string)
You can’t force a parameter of the function to be stored as number because the function itself is specting a string.
As Mixen suggest you store the user.score as String then convert that string to number
To store the value use VariableString(user.score)
To retrieve the value use ToNumber(userscorestring)) where userscorestring is the value you get from the call as string.
So there are no option to store a number to Firebase
I don’t know if is possible to save numbers take a look here maybe helps
If you use “Get a field” your variable stored as a string will be automatically a number, without converting.
I don’t know what about queries, have never used them.