I know that I can create a new query to read the doc by id in callback. But can I get the whole snapshot in the callback after creating document or at least TIMESTAMP?
firebase.firestore().collection("comments").add({
body: data
})
.then(comment => {
console.log(comment);
})
.catch(error => {
console.log(error);
});
Calling
CollectionRef.add(...)
return a reference to the newly created document. To be able to access the data of that new document you'll need to still load it. So:For a working example, see: https://jsbin.com/xorucej/edit?js,console