Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67469

Problem with adding a new document in Firestore

$
0
0

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


Viewing all articles
Browse latest Browse all 67469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>