Skip to content

Commit

Permalink
Feat: getAllDocument 내림 차순 정렬로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
BearHumanS committed Jan 16, 2024
1 parent 0497dfc commit f7cc42a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/firebaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
getCountFromServer,
getDoc,
getDocs,
orderBy,
query,
setDoc,
updateDoc,
} from 'firebase/firestore';
Expand Down Expand Up @@ -54,7 +56,9 @@ export const setDocument = async (documentPath: string, data: DataObject) => {

export const getAllDocument = async (collectionPath: string) => {
const ref = collection(db, collectionPath);
const querySnapshot = await getDocs(ref);

const refQuery = query(ref, orderBy('createdAt', 'desc'));
const querySnapshot = await getDocs(refQuery);

const documents = querySnapshot.docs.map((doc) => ({
id: doc.id,
Expand Down

0 comments on commit f7cc42a

Please sign in to comment.