2021年3月29日星期一

How to query one field and sort by another in Firebase RTDB with custom index

I am working with a project using Firebase RTDB (not CFS). I am wondering if there is a way to query one thing and sort by another. I realize there is no way to do this natively, but maybe with some kind of composite indexes like in querybase. Here is what I want:

users    123232123      followers        billy: true        molly: true      lastDate: 33021    23920200      followers        billy: true        jon: true      lastDate: 32921  

I would like to query something like orderBy('billy').equalTo(true), and then orderBy('lastDate').

Or basically where billy = true && sort by lastDate

I am open to new data modeling techniques.

Theoretically this is possible with any 2 other fields like so:

followers    billy_32921: true  ...  followers    billy_33021: true  

This is not the correct way to combine the fields. I have been trying to read this post. How do I combine a date field with a set item?

The problem I believe is that there can be more than one follower. How do I combine a

I am unsure on how to model this and query it.

Any ideas?

Thanks,

J

https://stackoverflow.com/questions/66863705/how-to-query-one-field-and-sort-by-another-in-firebase-rtdb-with-custom-index March 30, 2021 at 09:38AM

没有评论:

发表评论