javascript - Equivalent of .push in Firestore? - Stack Overflow

I am trying to convert my firebase implementation which previously used realtime database to use firest

I am trying to convert my firebase implementation which previously used realtime database to use firestore as I like the idea of collections and the perks of using it.

How do I implement below into firestore equivalent?

firebase.database().ref('documentPath').push()

I am trying to convert my firebase implementation which previously used realtime database to use firestore as I like the idea of collections and the perks of using it.

How do I implement below into firestore equivalent?

firebase.database().ref('documentPath').push()
Share Improve this question asked Jun 19, 2018 at 7:50 Jojo NarteJojo Narte 3,1142 gold badges33 silver badges57 bronze badges 1
  • firebase.google./docs/firestore/manage-data/… – André Kool Commented Jun 19, 2018 at 9:18
Add a ment  | 

1 Answer 1

Reset to default 13

To have the same bahaviour in Cloud Firestore as you have in Firebase Realtime database when using the push() function, is to let Cloud Firestore auto-generate an ID for you. You can do this by calling add() function like this:

var addYourDoc = db.collection('documentPath').add({
  property_key: 'property_value',
}).then(ref => {
  console.log('document ID: ', ref.id);
});

The output in the console will be the actual generated id.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743649227a4484279.html

相关推荐

  • javascript - Equivalent of .push in Firestore? - Stack Overflow

    I am trying to convert my firebase implementation which previously used realtime database to use firest

    3天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信