Auto increment a value in firebase with javascript

后端 未结 5 2103
野性不改
野性不改 2020-12-03 14:52

Hello I\'m working on some firebase project and i can save my datas via javascript into firebase database. But i couldn\'t figure it out to auto increment child value (my ch

5条回答
  •  旧时难觅i
    2020-12-03 15:15

    Firebase has no auto-incrementing keys, since those don't work well in massively multi-user systems where clients can be offline for prolonged periods.

    Instead, Firebase has its own type of auto-generated keys called push IDs. These push IDs have the same important properties of sequences in many relational databases: they are ordered and sequential. But in addition, they can be calculated client-side, even when the client is not connected to the Firebase servers.

    See the Firebase documentation on saving data in lists, this legacy blog post on why arrays don't work well in Firebase and this post on how push ids work.

提交回复
热议问题