I have a collection in a firebase. I'm listening to changes with onSnapshot
method.
If any item from a collection is changed in any way listener is fired. I am getting new data, which was inserted into my collection with docChanges
method
db.collection('collection')
.onSnapshot((snapshot) => {
snapshot.docChanges().forEach((change) => {
const payload = {
id: change.doc.id,
data: change.doc.data(),
};
...... some action
});
});
and now... I need to compare new data (which was just inserted) with old data (from before insert) and I am wondering if there is any way to do that?