Updating a field inside a firebase firestore doc without hand write the field key to update Angular

后端 未结 1 908
清酒与你
清酒与你 2021-01-28 10:05

How could i update a doc inside my firestore without precisely write in the code the field i want to update , cause already is reached through the form: .Lets say the HTML tag i

相关标签:
1条回答
  • 2021-01-28 10:25

    if you have reference to object in firebase

    const path = this.docCreator
      .collection('users')
      .doc(this.userdata.uid)
      .collection('Incomings')
      .doc(this.userdata.uid);
    

    you can crete empty object and use key name from dataToPass.key to set property

    let foo: any = {};
    foo[`${dataToPass.key}`] = dataToPass.import;
    path.update(foo);
    
    0 讨论(0)
提交回复
热议问题