简体   繁体   中英

Firebase Firestore - differences between mobile and web SDK

I wonder where the differences between the SDK comes from. For example, I have a list of news. I perform two operations on it: refresh and download the first or next offset. When I am using a mobile SDK and I will call this for refreshing:

FirebaseFirestore.getInstance().collection("news")
.whereEqualTo("categories.finance", true)
.whereEqualTo("locale", "pl")
.orderBy("timestamp", Query.Direction.DESCENDING)
.limit(15)
.endAt(1518554580)
.get()

It will return the latest news. But if I will execute it on cloud functions:

admin.firestore().collection('news')
.where('categories.finance', '==', true)
.where('locale', '==', language)
.limit(15)
.orderBy('timestamp', 'desc')
.endAt(1518554580)
.get()

I am getting an empty list. The same applies to downloading offsets. Query looks like above with one difference - I am using startAfter(1518554580).

Why is this happening? Is there a way to solve this?

I know why this is happening. For some reason, compound index with descending timestamp works for mobile, but for web it's working when index is ascending. For this reason, I must have two indexes for each category.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM