【问题标题】:Cloud Function ArrayRemove not deleting array value, but function runs without errorCloud Function ArrayRemove 不删除数组值,但函数运行没有错误
【发布时间】:2022-01-06 23:44:51
【问题描述】:

我的云函数没有从它应该删除的数组中删除值。正如我在调试控制台中看到的那样,它正确获取了所有值,但数组中的值仍然存在。

我的代码语句如下:

  for (const id of membersUnderStructure){
    const ele = context.params.structure;
    console.log(`Deleting ${ele} From ${id}`);
    await db.collection(`TeamMember`)
    .doc(id)
    .update({teamStructIds: admin.firestore.FieldValue.arrayRemove(ele)})

我知道问题出在 admin.firestore.... 行,就好像我在那里放了一个常量值一样,它确实可以正常更新。我的控制台也显示了 'ele' 和 'id' 的正确值,因此这些值是正确的。该函数执行 'ok' 没有任何错误,但不会从 'teamStructIds' 数组中删除 'ele' 的值。

我不确定我在这里做错了什么?

【问题讨论】:

    标签: node.js firebase google-cloud-firestore


    【解决方案1】:

    解决方案:

    数组是“数字”,它正在尝试删除一个字符串“ele”。 我刚刚更改为 parseInt(context.parama.structure),它现在可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      相关资源
      最近更新 更多