我想获取文档的 id,但是当我在 console.log 时却没有定义 有没有办法同时包含文档 ID?
this.unsubscribe = FirestoreService.getMessagesSnapshot(selected.id, selected.userId).onSnapshot((querySnapshot) => {
if(querySnapshot.size > 0) {
let tempObject = [];
querySnapshot.forEach((doc) => {
tempObject.push({
**id:doc.id,**
chatId: doc.data().chatId,
membersId: doc.data().membersId,
name: selected.name,
picRatio: doc.data().picRatio,
picUrl: doc.data().picUrl,
fileUrl: doc.data().fileUrl,
senderId: doc.data().senderId,
text: doc.data().text,
thumbUrl: doc.data().thumbUrl,
time: doc.data().time.toDate(),
videoUrl: doc.data().videoUrl,
});
});