0

My groupId argument is not recognized on updateDoc function while other parameters are recognized. groupId is only recognized on updateUserGroups level.

async function updateUserGroups(userId, groupId, groupData) {
    const userDoc = await getDocById('users', userId)
    if (userDoc.data()['user_groups'] === undefined) {
        updateDoc('users', userId, {
            'user_groups': { groupId: groupData['creation_time'] }
        })
    }
}

Why is that?

genericUser
  • 4,417
  • 1
  • 28
  • 73
  • You're using `groupId` as a literal key, not a variable. You need to write `{[groupId]: groupData['creation_time']}` – Barmar Feb 14 '21 at 17:45

1 Answers1

1

I think you meant to do:

'user_groups': { [groupId]: groupData['creation_time'] }

Instead of:

'user_groups': { groupId: groupData['creation_time'] }

Because if you don't put the [], the name of the property (the key) will just be groupId, it's name (the key) will not be equal to what is stored in groupId

Silidrone
  • 1,471
  • 4
  • 20
  • 35