How do add document in a subcollection of a firebase database

Hello,

I am facing an issue, and for the moment I haven’t found a solution.

I have designed a firebase/firestore database with sub-collection and reference to other document inside it (like a one-to-many relation)

collection ingredients
name 
......

collection recipe :
        title
        content
        sub-collection > ingredient
                                      reference to ingredients collection

How can I create this reference during the creation query of my document ?
I have try :

{
	"ingredient": {{"projects/[FIREBASE_PROJECT_ID]/databases/ingredient/" + recipeIngredientSelect.value}},
[...]
}
{
	"ingredient": {{"ingredients/" + recipeIngredientSelect.value}},
[...]
}

But when the document is created, the type of field “ingredient” is string and not a reference to the document.

Any ideas ?

Thanks !

Hello, could you please send me a screenshot of your Firestore like this?

Hello :
Ingredient :

Reference to ingredient document :

Could you please send a screenshot of the Appsmith queries that you want to try to execute?

It seems that currently we can’t send a reference from Appsmith to Firestore I opened a feature request to allow us to select the type of data we want to send to Firestore. You can track it at this
link:[Feature]: Specify the type of data to load in Firestore · Issue #20691 · appsmithorg/appsmith · GitHub

Hello,

Thanks for the feature submission.

For the moment, I found a workaround,
I send to firebase a map object :

{
"ref_object": {
  "path" : "collection/OBJECTID",
  "id" : "collection/OBJECTID"
},
"field": "value"
}

It’s not ideal, but it’s working !

Thanks !

Hello, thank you very much for the solution, it will be very useful.