-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to have sections in FirebaseTableViewDataSource #8
Comments
@kermankohli Yep, this would definitely be useful. I put some thought into this earlier, and my original thought was to use separate refs, so you would create a This might fit in well for our eventual support for better client side filtering, so definitely on the roadmap after auth. It requires an array of arrays to support sections, adding |
@mcdonamp Alright, thanks for that! I'm not implementing Firebase right now but will be looking to move in about a month - do you reckon it'd be implemented by then? |
Thanks to @pmodernme, it might be earlier: #13 |
@mcdonamp looks pretty good, thanks @pmodernme! 馃憤 |
Happy to be of use!
|
Hey guys just had a question, If the refQuery was users/john/tasks (which contains the IDs of all the users), how would filtering/sorting work in that case? |
@kermankohli If you don't set the predicate, or the sort descriptors (set them to nil), it will sort the snapshots alphabetically by key. If you set the sortDescriptors (this is an array of
or
You have to use a key path like Predicates work much in the same way. You set the predicate to an NSPredicate.
Only snapshots with the child I hope that helps! |
Thanks for such a detailed write up! Just read back on what I wrote and I ended up confusing my self 馃憥 What I meant to say was if the refQuery was /users/john/tasks/ (which contains an array of tasks who's ids correspond to the task class) then how would sorting work, because the values themselves haven't been fetched. Sorry for the confusion before! |
What you're asking about is join functionality on top of the filtering, which we don't currently support. We're investigating something similar to what Firebase-Util offers in that respect, but, to be honest, doing all of that client side is really not something that we're interested in doing from a performance standpoint. |
Yeah it's kinda an edge case which might not be worth developing for. Would it be fine if I structured my data to look like /tasks/john/taskX rather /tasks/(tasks from /users/john/tasks/)? |
It's a totally valid use case, it's just not something we support out of the box on the backend (being the type of NoSQL database we are). It's fine if you structure it that way, the issue is just that potentially pulling down all that task data and sorting it client side could be a pretty expensive operation. Typically I recommend only pulling down the minimum amount of data required to sort/filter client side and then attach listeners on the relevant tasks/objects and grab those more full changes. Typically, for instance, you aren't filtering off the title or the description of the task (and those are relatively big), but you might be filtering off timestamps/tags, so keep the title/description in |
Right gotchya. In my case I need to sort/filter by 5 keys, so in that case I'll need to store all that information in users/john/tasks/$taskID? |
Ah! I have something similar in my own app. You have to sort or fetch by |
That makes sense! Doesn't it lead to duplication of data though? Or is this normal when you denormalize data (I'm new to this haha)? |
Yes, it can, though this is more normal in a NoSQL database--disk space is cheap, your time is not. It's effectively creating indices rather than relying on the DB to do so. Plus, with multi-writes in Firebase, it's easy to keep these values in sync. |
Closing because pull #13 deals with this |
I've built an NSFetchedResultsController type solution for the Firebase Realtime Database, and I've just open sourced it. I've been using this in a few of my production apps for some time now. https://github.com/cgossain/FirebaseResultsController I'd love to hear your thoughts. |
It'd be really helpful if FirebaseTableViewDataSource.m allowed for UITableViewSections based on a specific variable. Basically something similar to NSFetchedResultsController used for Core Data 馃憤
The text was updated successfully, but these errors were encountered: