Im researching Cloud Firestore(Java project) and i've got a question. In firestore collection(VIN)/document(VIN_NUMBER)/fields data structure, I am subscribing to get realtime updates on the database with code as below:
firestore.collection(FirestoreGateway.FIRESTORE_COLLECTION_FLAT)
.addSnapshotListener((snapshots, e) -> {
if (e != null) {
System.err.println("Listen failed: " + e);
return;
}
for (DocumentChange dc : snapshots.getDocumentChanges()) {
switch (dc.getType()) {
case ADDED:
System.err.println("ADDDED: " + dc.getDocument().getData());
break;
case MODIFIED:
System.err.println("Modified: " + dc.getDocument().getData());
break;
case REMOVED:
System.err.println("Removed: " + dc.getDocument().getData());
break;
default:
break;
}
}
});
Is there a way to get actual field that changed inside the document? The code above just returns a Map with refreshed values(I want only value that changed).