Write/update number instead of string to firebase document

I can create a document in firebase with a field that is a number instead of string. I seem not to be able to write or update a firebase document its field with a number though. Gdevelop says it expects a string. Is there any way I can update number fields in firebase documents?

Or do i have to convert a string to number back and forth in gdevelop? That would not be preferable for keeping score. Also regarding a query that i make later on at the document to sort them in ascending order.

Any help greatly appreciated.

1 Like

You can use the “update a document” action with a structure variable that has a child named after your field set to your number.

1 Like

Yes it is possible but then I can not order the query in descending order on value anymore. Why can I not just write a number to the database instead of a string/structure?

There is no difference between writing a field and updating a document with a structure, you seem to be missunderstanding. A document is always a map between fields and value, it is equivalent to a structure. Updating the document with a structure sets all the children of the structure as fields in the document directly. If you want your field “id” of your document to be set to 4, simply set the child variable “id” of a temporary structure variable to the numeric value 4 and update the document with that variable.

1 Like

You are right I was misunderstanding it. I got it now. Need to write everything in a structure to begin with. Sorry for the late reaction I was caught away on another project back on track. Sorry to have bothered with this,the question can be closed. Thanks so much.