diff --git a/android/src/main/java/io/invertase/firebase/firestore/FirestoreSerialize.java b/android/src/main/java/io/invertase/firebase/firestore/FirestoreSerialize.java index 3bcb84ec..8bdbc7e3 100644 --- a/android/src/main/java/io/invertase/firebase/firestore/FirestoreSerialize.java +++ b/android/src/main/java/io/invertase/firebase/firestore/FirestoreSerialize.java @@ -30,7 +30,7 @@ public class FirestoreSerialize { static WritableMap snapshotToWritableMap(DocumentSnapshot documentSnapshot) { WritableMap documentMap = Arguments.createMap(); - documentMap.putString(KEY_PATH, documentSnapshot.getId()); + documentMap.putString(KEY_PATH, documentSnapshot.getReference().getPath()); documentMap.putMap(KEY_DATA, objectMapToWritable(documentSnapshot.getData())); // Missing fields from web SDK // createTime diff --git a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseDocumentReference.java b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseDocumentReference.java index 561e2896..fe0f7219 100644 --- a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseDocumentReference.java +++ b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseDocumentReference.java @@ -69,11 +69,14 @@ public class RNFirebaseDocumentReference { public void set(final ReadableMap data, final ReadableMap options, final Promise promise) { Map map = Utils.recursivelyDeconstructReadableMap(data); + Task task; SetOptions setOptions = null; if (options != null && options.hasKey("merge") && options.getBoolean("merge")) { - setOptions = SetOptions.merge(); + task = this.ref.set(map, SetOptions.merge()); + } else { + task = this.ref.set(map); } - this.ref.set(map, setOptions).addOnCompleteListener(new OnCompleteListener() { + task.addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { @@ -89,7 +92,7 @@ public class RNFirebaseDocumentReference { }); } - public void update(final ReadableMap data, final ReadableMap options, final Promise promise) { + public void update(final ReadableMap data, final Promise promise) { Map map = Utils.recursivelyDeconstructReadableMap(data); this.ref.update(map).addOnCompleteListener(new OnCompleteListener() { @Override diff --git a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java index 382f1708..12c4bc99 100644 --- a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java +++ b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java @@ -67,11 +67,12 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule { break; case "SET": Map options = (Map) write.get("options"); - SetOptions setOptions = null; if (options != null && options.containsKey("merge") && (boolean)options.get("merge")) { - setOptions = SetOptions.merge(); + batch = batch.set(ref, data, SetOptions.merge()); + } else { + batch = batch.set(ref, data); } - batch = batch.set(ref, data, setOptions); + break; case "UPDATE": batch = batch.update(ref, data); @@ -135,9 +136,9 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule { } @ReactMethod - public void documentUpdate(String appName, String path, ReadableMap data, ReadableMap options, final Promise promise) { + public void documentUpdate(String appName, String path, ReadableMap data, final Promise promise) { RNFirebaseDocumentReference ref = getDocumentForAppPath(appName, path); - ref.update(data, options, promise); + ref.update(data, promise); } /* diff --git a/lib/modules/firestore/CollectionReference.js b/lib/modules/firestore/CollectionReference.js index 98000ab1..3c53be1d 100644 --- a/lib/modules/firestore/CollectionReference.js +++ b/lib/modules/firestore/CollectionReference.js @@ -6,7 +6,7 @@ import DocumentReference from './DocumentReference'; import Path from './Path'; import Query from './Query'; import QuerySnapshot from './QuerySnapshot'; -import firestoreAutoId from '../../utils'; +import { firestoreAutoId } from '../../utils'; import type { Direction, Operator } from './Query';