创建文档密钥后是否可以立即获取?

时间:2020-04-21 23:50:41

标签: javascript firebase react-native google-cloud-firestore

在添加这些数据之后,我想获得本文档的参考。

有可能吗?

await userCycleCollectionRef.doc().set({
    userUid,
    startDate,
    endDate,
});

1 个答案:

答案 0 :(得分:1)

如您从API documentation所见,

userCycleCollectionRef.doc()立即返回DocumentReference。

const ref = userCycleCollectionRef.doc()
await ref.set({
    userUid,
    startDate,
    endDate,
});