如何获取Firebase生成的ID?

时间:2022-12-07 22:03:09

I want to update an item in my application so I need an id that Firebase creates:

我想更新应用中的项目,因此我需要Firebase创建的ID:

https://db.firebaseio.com/userid/books/-L6_e2KsseGzwM8a0YUv

https://db.firebaseio.com/userid/books/-L6_e2KsseGzwM8a0YUv

The problem is that Firebase returns an object of objects, so I returned Object.values(data) and now I don't have that id which I could maybe access if Firebase returns classic array..

问题是Firebase返回一个对象对象,所以我返回了Object.values(数据),现在我没有那个我可以访问的id,如果Firebase返回经典数组的话。

1 个解决方案

#1


0  

you will get the key of the object by object.key. and for value you can do object.val() For multiple object you can try Object.keys() and Object.values() Is this you wanted? I can be more specific if you can post the block of code.

您将通过object.key获取对象的键。对于值,您可以执行object.val()对于多个对象,您可以尝试Object.keys()和Object.values()这是您想要的吗?如果您可以发布代码块,我可以更具体。

#1


0  

you will get the key of the object by object.key. and for value you can do object.val() For multiple object you can try Object.keys() and Object.values() Is this you wanted? I can be more specific if you can post the block of code.

您将通过object.key获取对象的键。对于值,您可以执行object.val()对于多个对象,您可以尝试Object.keys()和Object.values()这是您想要的吗?如果您可以发布代码块,我可以更具体。