我正在尝试转换我的FireBase实现,它以前使用实时数据库来使用FireStore,因为我喜欢收集和使用它的好处。
我如何实现下面的FireStore等价物?
firebase.database().ref('documentPath').push()
当使用 push() 函数的作用是让云FireStore自动为您生成一个ID。你可以打电话来 add() 功能如下:
push()
add()
var addYourDoc = db.collection('documentPath').add({ property_key: 'property_value', }).then(ref => { console.log('document ID: ', ref.id); });
控制台中的输出将是实际生成的ID。