컬렉션 데이터 가져오기
컬렉션의 모든 데이터 가져오기
import { collection, getDocs } from "firebase/firestore";
import { db } from "@/FirebaseApp";
export default async function getDataFeed() {
const collectionRef = collection(db, "feeds"); //✅ 컬렉션 참조 생성
const snapshot = await getDocs(collectionRef); //✅ 모든 문서 조회
const documents = snapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}));
console.log(documents); //✅ 조회된 문서의 데이터 출력
}컬렉션 내 특정 문서 가져오기
Last updated