In firebase, I have a string field and I want to use batch writes to either delete this field or set it to null. I tried the code below but nothing happend.
import { firestore } from 'firebase-admin';
...
try {
const batch = firestore.batch();
batch.update(docRef, {
myField: firestore.FieldValue.delete(),
});
await batch.commit();
} catch (error) {
clog.error({ error }, `Failed to abort A/B test`);
throw new Error(error);
}
...
I tried to replace firestore.FieldValue.delete()
by null
and it didn’t work either.
I tried to replace it by 'aaa'
and it worked and set myField
to aaa
.