1

I have the following code

admin.firestore().collection("projects")
.doc(projectId)
.update({[`members.${email}`]: "member"});

the value of the variable email is = "email@gmail.com"

and the result is

{
  members: {
    email@gmail: {
     com: "member"
    }
  }
}

expected result is

{
  members: {
    email@gmail.com: "member"
  }
}

I can use FiealPath in android(Kotlin) but how to use it in cloud functions (JavaScript)

Jeken
  • 13
  • 6

2 Answers2

0

You need to think as JSON keys for the key values. You cannot use dots or special characters that JSON does not support for keys. You could create a parser to change dots for other characters in order to store them in Firebase and then parse them again in the apps.

Juanje
  • 1,235
  • 2
  • 11
  • 28
0

to update nested objects in typescript you can use

admin.firestore().collection('projects').doc('projectid')
.update(members: {
[`${email@gmail.com}`]: "member"
})
Dev
  • 1,308
  • 3
  • 13
  • 24