Web v9 Firestore: Get Multiple Documents by Id

May 6, 2022
import { collection, doc, documentId, query, where, getDocs } from "firebase/firestore";const db = ... // firestoreconst blogIds = ['blog-id-01', 'blog-id-02', 'blog-id-03']// const refs = blogIds.map(id => doc(collection(db, 'blog'), id))const snap = await getDocs(query(collection(db, 'blog'), where(documentId(), "in", blogIds)))const blogs = snap.docs.map(doc => {  const item = doc.data()  item.id = doc.id  return item})

NOTE: In array query allowed max of 10 items

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.