Delete a field from Firestore, with a dynamic key

I had to import FieldValue

https://firebase.google.com/docs/firestore/manage-data/delete-data#fields

        // Get the `FieldValue` object
        var FieldValue = require('firebase-admin').firestore.FieldValue;
        
        // Create a document reference
        var cityRef = db.collection('cities').doc('BJ');
        
        // Remove the 'capital' field from the document
        var removeCapital = cityRef.update({
          capital: FieldValue.delete()
        });

I have managed to delete a field like this:

let userId = "this-is-my-user-id"
let groupId = "this-is-my-group-id"

db.collection('groups').doc(groupId).update({
  ['members.' + userId]: firebase.firestore.FieldValue.delete()
})

This is using the dot operator method described here

Please let me know if there are any alternative methods to this

Thanks