본문 바로가기

Firebase

파이어베이스 데이터 정렬 및 제한 꼭 알아야할 주의사항

반응형
https://firebase.google.com/docs/firestore/query-data/order-limit-data

https://stackoverflow.com/questions/54244722/firestore-invalid-query-am-i-using-indexing-wrong

 

필터를 orderBy()  limit() 결합할  있습니다다음 예시의 쿼리에서는 인구 기준을 정의하고,

인구를 오름차순으로 정렬하며기준을 초과하는 처음  개의 결과만 반환합니다.

그러나 필터에 범위 비교(<, <=, >, >=) 포함된 경우 동일한 필드를 기준으로 1 정렬이 이루어져야 합니다.

 

    const postDB = await dbService
      .collection("PostDB")
      .where("upVote", ">=", 0)
      .orderBy("upVote")
      .orderBy("time", "desc")
      .limit(1);

 

반응형