๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โ—๏ธError

[Firebase Error ํ•ด๊ฒฐ๋ฒ• ํฌํ•จ] Invalid query. You are trying to start or end a query using a document for which the field 'timeStamp' is an uncommitted server timestamp.

by Fomagran ๐Ÿ’ป 2021. 4. 8.
728x90
๋ฐ˜์‘ํ˜•

 

์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค!

 

์˜ค๋Š˜์€ ์ฑ„ํŒ…์•ฑ์„ ๋งŒ๋“ค๋ฉด์„œ ๋งŒ๋‚˜๊ฒŒ ๋œ ์—๋Ÿฌ์ž…๋‹ˆ๋‹ค.

 

์ƒํ™ฉ์„ค๋ช…์„ ๊ฐ„๋‹จํžˆ ํ•˜๋ฉด ์ฑ„ํŒ…์•ฑ์„ ๋งŒ๋“ค๋•Œ ์œ ์ €๊ฐ€ ํ™•์ธํ•œ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ๋ฉ”์„ธ์ง€์˜ ๋ฌธ์„œ๋ฅผ ๊ธฐ์–ตํ•ด๋‘๊ณ 

 

๋‹ค์‹œ ์œ ์ €๊ฐ€ ๋ณผ๋• ์ฑ„ํŒ…์ด๋ผ๋Š” ์ปฌ๋ ‰์…˜์—์„œ ํƒ€์ž„์Šคํƒฌํ”„๋กœ ์ •๋ ฌํ•œ ๋’ค ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ๋ฌธ์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๊ทธ ๋’ค 10๊ฐœ๊นŒ์ง€๋งŒ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

collectionRef(.ChattingRoom).document(documentID).collection("Chat").order(by:"timeStamp",descending: true).end(beforeDocument: endDocument!).limit(to: 10)

 

ํ•˜์ง€๋งŒ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์—๋Ÿฌ ๊ฐ€ ๋–ด์Šต๋‹ˆ๋‹ค...

 

์ž˜๋ชป๋œ ์ฟผ๋ฆฌ๋ผ๊ณ  ํ•˜๋Š”๋ฐ ํ•ด์„ํ•ด๋ณด๋ฉด 

 

'์ž˜๋ชป๋œ ์ฟผ๋ฆฌ์ž…๋‹ˆ๋‹ค. 'timeStamp' ํ•„๋“œ๊ฐ€ ์ปค๋ฐ‹๋˜์ง€ ์•Š์€ ์„œ๋ฒ„ ํƒ€์ž„์Šคํƒฌํ”„์ธ ๋ฌธ์„œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฟผ๋ฆฌ๋ฅผ ์‹œ์ž‘ํ•˜๊ฑฐ๋‚˜ ์ข…๋ฃŒํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. (์ด ํ•„๋“œ์˜ ๊ฐ’์„ ์•Œ ์ˆ˜ ์—†์œผ๋ฏ€๋กœ ์ด ํ•„๋“œ๋กœ๋Š” ์ฟผ๋ฆฌ๋ฅผ ์‹œ์ž‘/์ข…๋ฃŒํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค .'

 

๋ผ๊ณ  ํ•˜๋„ค์š”.

 

์ „ ์ด๊ฒŒ ์ดํ•ด๊ฐ€ ์ž˜์•ˆ๋ผ์„œ ๊ตฌ๊ธ€๋ง์„ ํ•ด์„œ ์ฐพ์•„๋ณธ ๊ฒฐ๊ณผ ์ €์™€ ๋˜‘๊ฐ™์€ ์ด์Šˆ๋กœ ํŒŒ์ด์–ด๋ฒ ์ด์Šค ๊นƒํ—ˆ๋ธŒ์— ์งˆ๋ฌธํ•œ ์‚ฌ๋žŒ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

 

๊ฑฐ๊ธฐ์„œ ๋‹ฌ๋ฆฐ ๋‹ต๋ณ€์„ ์š”์•ฝํ•˜๋ฉด

 

ํŽ˜์ด์ง€๋„ค์ด์…˜๊ณผ ํƒ€์ž„์Šคํƒฌํ”„๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ํ˜ธํ™˜๋˜์ง€ ์•Š์œผ๋ฉฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ ํ•ด๋‹น ๋ฌธ์„œ์˜ ํƒ€์ž„์Šคํƒฌํ”„๋ฅผ ๊ธฐ์–ตํ•˜๊ณ  ํƒ€์ž„์Šคํƒฌํ”„๋ฅผ

 

์ด์šฉํ•˜์—ฌ end(beforeDocument:) ๋Œ€์‹  end(before:[TimStamp]) ๋ฉ”์†Œ๋“œ๋กœ ๋Œ€์‹ ํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

collectionRef(.ChattingRoom).document(documentID).collection("Chat").order(by:"timeStamp",descending: true).end(before: [endTimeStamp!]).limit(to: 10)

 

ํ˜น์‹œ๋ผ๋„ ๋” ๋‚˜์€ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์„ ์•„์‹œ๊ฑฐ๋‚˜ ํ‹€๋ฆฐ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์„ธ์š”!

 


Reference

 

 

 

IllegalArgumentException: Invalid query · Issue #736 · firebase/firebase-android-sdk

Environment Android Studio version: 3.5 Firebase Component: Firestore Component version: 21.0.0 Problem I'm adding a new document in firestore. After adding a new document when I come back to m...

github.com

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€