Currently, I am developing a project with vuejs and I am facing an issue where I need to fetch only the last created item from Firestore's realtime database. However, when I execute the following code snippet, it retrieves all items from the database instead.
getRealtime() {
db.collection("items").onSnapshot(doc => {
doc.docChanges().forEach(function(change) {
if (change.type === "added") {
console.log(change.doc.data());
}
});
})
}