gpt4 book ai didi

javascript - AngularFire推送功能

转载 作者:行者123 更新时间:2023-12-03 03:56:04 25 4
gpt4 key购买 nike

我正在使用 Angularfire,如下所示:

 this.afDB.list('/items/' + this.itemID).push({displayName: item.name}); 

结构如下所示,其中 itemIDqoieke

items:
- qoieke:
- Leow9dnfwoierjhwelo
- displayName: "Something"

我不明白的是如何避免将“Leow9dnfwoierjhwelo”自动生成的ID?

所以,我想要如下的结构:

items:
- qoieke:
- displayName: "Something"

谢谢!

最佳答案

调用push会生成一个所谓的推送ID。为了不生成它,请不要调用push。而是调用 set() (用您传入的值替换该位置的当前值)或 update() (仅修改您传入的属性)。

在您的情况下, update() 似乎可以满足您的要求:

this.afDB.list('/items/' + this.itemID).update({displayName: item.name}); 

关于javascript - AngularFire推送功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44942658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com