I am a newcomer to utilizing firebase and my objective is to read all data in a collection just once, then continuously fetch new updates without the need to refetch all the data when refreshing or closing the web app.
Is this achievable?
<pre>db.collection("cities").where("state", "==", "CA")
.onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
if (change.type === "added") {
console.log("New city: ", change.doc.data());
}
if (change.type === "modified") {
console.log("Modified city: ", change.doc.data());
}
if (change.type === "removed") {
console.log("Removed city: ", change.doc.data());
}
});
});
</pre>