@@ -149,10 +149,10 @@ class FirestoreAPIProvider extends APIProvider with LiveAPIProvider {
149149 } else if (result is DocumentReference ) {
150150 // Handle DocumentReference for 'add' operations
151151 body = {'id' : result.id, 'path' : result.path};
152- } else if (result == null ) {
152+ } else if (result is DocumentSnapshot ) {
153153 // Handle void results for 'set', 'update', and 'delete' operations
154- body = {'message ' : 'Operation completed successfully' };
155- } else {
154+ body = {'document ' : getDocument (result) };
155+ } else if (result == null ) {
156156 // Fallback for unexpected types, you might not need this, but it's here just in case
157157 body = {'message' : 'Unknown response type' , 'details' : result.toString ()};
158158 }
@@ -167,15 +167,17 @@ class FirestoreAPIProvider extends APIProvider with LiveAPIProvider {
167167
168168 List <Map <String , dynamic >> getDocuments (QuerySnapshot snapshot) {
169169 return snapshot.docs.map ((doc) {
170- // Create a new map from the document data
171- Map <String , dynamic > data =
172- convertFirestoreTypes (doc.data () as Map <String , dynamic >);
173- // Add the document ID under a reserved/special key
174- data['_documentId' ] = doc.id;
175- return data;
170+ return getDocument (doc);
176171 }).toList ();
177172 }
178-
173+ Map <String , dynamic > getDocument (DocumentSnapshot doc) {
174+ // Create a new map from the document data
175+ Map <String , dynamic > data =
176+ convertFirestoreTypes (doc.data () as Map <String , dynamic >);
177+ // Add the document ID under a reserved/special key
178+ data['_documentId' ] = doc.id;
179+ return data;
180+ }
179181 Map <String , dynamic > convertFirestoreTypes (Map <String , dynamic > input) {
180182 Map <String , dynamic > convert (Map <String , dynamic > map) {
181183 final Map <String , dynamic > newMap = {};
@@ -214,7 +216,9 @@ class FirestoreAPIProvider extends APIProvider with LiveAPIProvider {
214216 return item; // Return the item unchanged if it's not a Map, GeoPoint, or Timestamp
215217 }
216218 }).toList ();
217- } else {
219+ } else if (value is DocumentSnapshot ){
220+ newMap[key] = getDocument (value);
221+ } else {
218222 // For all other types, just copy the value
219223 newMap[key] = value;
220224 }
0 commit comments