Firebase firestore saving reference field in dropdown

I'm attempting make a form to insert a document into a firestore collection.
I'm working with a dropdown field that is a reference field in the collection.
when getting the data back the field contents looks like this.

{
  "$ref": "companies/pOjUBNOX9lHAsVkA2OEQ"
}

I can get my display values just fine with this

{{ query6.data.map(d=>d.name) }}

however, I cannot seem to make it save into firestore as a reference field, it is saving as a string instead.
here is my dropdown values code

{{ query6.data.map(d=>`{"$ref":"companies/` + d._id + `"}`) }}

any tips?

for anyone in the future that also has this issue....I heard back from support on Chat, and the solution was to parse the dropdown value in the query that saves the document (as opposed to doing it in the form element)
To recap - the js above are the field values in the dropdown of my form.
on submit, I will run a query to create a new document in firebase.
{{ JSON.parse(dropdown3.value) }}
here is what I had

{ "name": {{textinput2.value}}, "status": {{ dropdown2.value}}, "company": {{ dropdown3.value }} }

here it is after being fixed

{ "name": {{textinput2.value}}, "status": {{ dropdown2.value}}, "company": {{ JSON.parse(dropdown3.value) }} }

an added note: (this could just be a glitch)
I just found out that this parsed field cannot be the last in the payload.
e.g. this does not work

{"name": "Bob", "pet":"dog", "company": {{ JSON.parse(dropdown3.value) }} }

however this does work

{"name": "Bob",  "company": {{ JSON.parse(dropdown3.value) }} , "pet":"dog"}

Hi @jnui Thanks! What is the result in Firestore for your first example?

I tested this on my end and this query updates "company" to null in Firestore:


However, adding a space between {{ JSON.parse(dropdown3.value) }} and the closing } updates Firestore correctly:
It looks like your example does have a space between {{ JSON.parse(dropdown3.value) }} and the closing }, but I'm having trouble reproducing this error. If spacing is not the issue, feel free to reach out over chat. Happy to jump into your app to test

perhaps I changed the spacing at the same time I moved it.