简体   繁体   English

我可以在创建后立即获取文档密钥吗?

[英]Can I get the document key right after it is created?

Right after adding this data, I would like to have the reference of this document.添加此数据后,我希望获得此文档的参考。

it is possible?有可能的?

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

userCycleCollectionRef.doc() returns a DocumentReference immediately, as you can see from the API documentation . userCycleCollectionRef.doc()立即返回一个 DocumentReference,正如您从API 文档中看到的那样。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mongoose:如何将之后创建的文档中的数据传递到之前创建的文档中? - Mongoose: How do I pass data from a document created afterwards into a document created right before? 在用户做了正确的事情后,有没有办法摆脱我在 javascript 中创建的错误消息? - Is there a way to get rid of the error message I created in javascript after the user does the right thing? editly - 创建视频后在哪里可以获得返回值? - editly - Where can I get the return value after a video is created? 我可以使用 Firestore 获取使用 batch().set 创建的文档的生成 ID 吗? - Can I get the generated ID for a document created with batch().set using Firestore? 通过 querySelector 引用文档后,我的 React 应用程序出现错误 - 一切正常,直到我向右滚动到底部 - After referring to document by querySelector I get an error in my React app - everything works fine until I scroll right to the bottom 加密后无法得到正确的字母 - Can't get right letter after ciphering 如何使用document.write()创建JavaScript来执行? - How do I get JavaScript created with document.write() to execute? 推送后创建的对象的获取密钥(角度和Firebase) - Get Key for object created after Push (Angular and Firebase) 在Meteor中,如何将collectionFS图像链接到正确的文档? - In Meteor, how can I link a collectionFS image to the right document? 我可以在手动创建的文档模型上应用 jQuery 吗? - Can I apply jQuery on manually created document model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM