I have a collection in Firestore:
Collection(Models) ->Document(Fan) ->Collection(Assets)
And I want to add a new document to the collection(Assets)
Here's the HTML code:
<form>
<input type="text" id="asset_id" />
<button type="submit" id="submit">Submit</button>
</form>
Javascript code:
const assets = firestore.collection("Models").doc("Fan").collection("Assets");
document.querySelector('#submit').addEventListener('click', () => {
var asset_id = document.getElementById("asset_id").value;
addAsset(asset_id);
});
const addAsset = asset => {
assets.add({asset_type: asset});
};
but the code doesn't work and nothing is added to the collection