I am using javascript with CDN imports and I am trying to remove an element from an array within a batched write, however it seems that no matter what I try I keep getting errors with the most common being the following:
Uncaught (in promise) TypeError: FieldValue.arrayRemove is not a function
I use the following import for the firestore:
import { getFirestore, doc, getDoc, writeBatch, FieldValue } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-firestore.js";
I have tried a couple of solutions, the ones I can remember I have here below (here ‘theirUIDsDocRef’ is the reference to the document with the array, ‘UIDs’ is the name of the array and ‘myUID’ is a variable containing my UID which I want to delete):
batch.update(theirUIDsDocRef, { "UIDs": FieldValue.arrayRemove(myUID) });
batch.update(theirUIDsDocRef, "UIDs", FieldValue.arrayRemove(myUID));
batch.update(theirUIDsDocRef, { UIDs: FieldValue.arrayRemove(MyUID) });
If there is anything else you might need to know, please ask.