@@ -69,6 +69,7 @@ public Collection<T> get() {
69
69
FindIterable <Document > documents = collection .find ();
70
70
ArrayList <T > objects = new ArrayList <>();
71
71
for (Document document : documents ) {
72
+ document .append (storage .getKey (), document .get ("_id" ));
72
73
T object = StorageUtil .gson .fromJson (StorageUtil .gson .toJsonTree (document ), storage .getClassType ());
73
74
objects .add (object );
74
75
}
@@ -95,9 +96,12 @@ public void enableEventUpdates(Consumer<Exception> ec) {
95
96
try {
96
97
collection .watch ().forEach ((Consumer <? super ChangeStreamDocument <Document >>) x -> {
97
98
if (x .getOperationType () == OperationType .INSERT ) {
98
- storage .actions ().add (StorageUtil .gson .fromJson (StorageUtil .gson .toJsonTree (x .getFullDocument ()), storage .getClassType ()));
99
+ Document document = x .getFullDocument ();
100
+ document .append (storage .getKey (), document .get ("_id" ));
101
+ storage .actions ().add (StorageUtil .gson .fromJson (StorageUtil .gson .toJsonTree (document ), storage .getClassType ()));
99
102
} else if (x .getOperationType () == OperationType .UPDATE ) {
100
103
Document doc = collection .find (x .getDocumentKey ()).first ();
104
+ doc .append (storage .getKey (), doc .get ("_id" ));
101
105
storage .actions ().update (StorageUtil .gson .fromJson (doc .toJson (), storage .getClassType ()));
102
106
} else if (x .getOperationType () == OperationType .DELETE ) {
103
107
String key = x .getDocumentKey ().get ("_id" ).asString ().getValue ();
0 commit comments