firestore에서 collectionGroup을 사용하여 orderBy하고 싶습니다.
collection
에 대해서는 특히 아무것도 하지 않아도 index가 작성되고 있는 것 같기 때문에 orderBy
를 사용할 수 있다.하지만
collectionGroup
가되면 index는 자동으로 만들 수 없다는 것collection
컬렉션 얻기
const db = firebase.firestore()
db.collection("images").orderBy("timeStamp", "desc").limit(5).get()
이것은 제대로 내림차순으로 얻을 수 있습니다.
collectionGroup
컬렉션에 있는 하위 컬렉션 가져오기
필드
message: "テスト"
displayName: "testUser"
timeStamp: 2020年9月3日 14:10:46 UTC+9
db.collectionGroup("comment").orderBy("timeStamp", "desc").limit(10).get()
이렇게하면 다음 오류가 발생하여 얻을 수 없습니다.
Uncaught (in promise) FirebaseError: The query requires a COLLECTION_GROUP_DESC index for collection comment and field timeStamp. You can create it here
index
없기 때문에 할 수 없습니다.
라고 하는 것 같다
설정
firebase 콘솔 > firestore > 색인 > 단일 필드
collection group scope
라고 써 있는 곳이 모두 무효가 되어 있습니다.
除外を追加
선택

이번 경우라면 collectionGroup("comment")
그래서 コレクションID
에 comment
フィールドのパス
는 timeStamp
를 사용하고 싶으므로 timeStamp
컬렉션 그룹을 확인하십시오. Next

昇順
와 降順
를 사용하고 싶기 때문에 有効
로 저장

제외한 곳에 새로 설정한 항목이 표시됩니다.

이것으로 앞서와 같습니다.
db.collectionGroup("comment").orderBy("timeStamp", "desc").limit(10).get()
실행해보십시오.
제대로 내림차순으로 얻을 수있었습니다.
Reference
이 문제에 관하여(firestore에서 collectionGroup을 사용하여 orderBy하고 싶습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/yoshihide_tsukamoto/items/ad37dab65d4587f8be6e
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
const db = firebase.firestore()
db.collection("images").orderBy("timeStamp", "desc").limit(5).get()
컬렉션에 있는 하위 컬렉션 가져오기
필드
message: "テスト"
displayName: "testUser"
timeStamp: 2020年9月3日 14:10:46 UTC+9
db.collectionGroup("comment").orderBy("timeStamp", "desc").limit(10).get()
이렇게하면 다음 오류가 발생하여 얻을 수 없습니다.
Uncaught (in promise) FirebaseError: The query requires a COLLECTION_GROUP_DESC index for collection comment and field timeStamp. You can create it here
index
없기 때문에 할 수 없습니다.라고 하는 것 같다
설정
firebase 콘솔 > firestore > 색인 > 단일 필드
collection group scope
라고 써 있는 곳이 모두 무효가 되어 있습니다.
除外を追加
선택

이번 경우라면 collectionGroup("comment")
그래서 コレクションID
에 comment
フィールドのパス
는 timeStamp
를 사용하고 싶으므로 timeStamp
컬렉션 그룹을 확인하십시오. Next

昇順
와 降順
를 사용하고 싶기 때문에 有効
로 저장

제외한 곳에 새로 설정한 항목이 표시됩니다.

이것으로 앞서와 같습니다.
db.collectionGroup("comment").orderBy("timeStamp", "desc").limit(10).get()
실행해보십시오.
제대로 내림차순으로 얻을 수있었습니다.
Reference
이 문제에 관하여(firestore에서 collectionGroup을 사용하여 orderBy하고 싶습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/yoshihide_tsukamoto/items/ad37dab65d4587f8be6e
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
db.collectionGroup("comment").orderBy("timeStamp", "desc").limit(10).get()
Reference
이 문제에 관하여(firestore에서 collectionGroup을 사용하여 orderBy하고 싶습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/yoshihide_tsukamoto/items/ad37dab65d4587f8be6e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)