【发布时间】:2022-10-06 03:05:58
【问题描述】:
const messagesRef = collection(db, \'messages\')
const q = query(messagesRef, orderBy(\'createdAt\'), limit(25))
const [messages, loading] = useCollectionData(q)
// messages print fields of documents without id
需要获取文档的 ID,我想有一种方法可以在该钩子中传递选项,但 dk 如何。
如果没有办法使用该钩子获取 Id,那么选项是什么?
-
请在此处发布之前尝试解决您的问题。你读过文档吗?你试过什么了?为什么你的尝试没有成功,等等。也请阅读tour,阅读How to Ask 以及如何制作minimal reproducible example。
标签: reactjs firebase google-cloud-firestore react-hooks