📌  相关文章
📜  在 Cloud Firestore 中加入多个文档 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:04.908000             🧑  作者: Mango

代码示例2
let loadedPosts = {};
posts = db.collection('posts')
          .orderBy('timestamp', 'desc')
          .limit(3);
posts.get()
.then((docSnaps) => {
  docSnaps.forEach((doc) => {
    loadedPosts[doc.id] = doc.data();
    db.collection('users').child(doc.data().uid).get().then((userDoc) => {
      loadedPosts[doc.id].userName = userDoc.data().name;
    });
  })
});