Comments (17)
@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 FirebaseTableViewDataSource
and then add a section to it, and a section would contain a ref (or more likely a query). The approach mentioned above could allow for just a single ref, assuming you wanted to filter the data into sections based on the content of a single field.
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 inSection:indexPath.section
adding numberOfSections...
as [metaArray count]
and then updating the correct array every time an event is raised. PR's welcome if you wanted to try before we got to it :)
from firebaseui-ios.
@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?
from firebaseui-ios.
Thanks to @pmodernme, it might be earlier: #13
from firebaseui-ios.
@mcdonamp looks pretty good, thanks @pmodernme! 👍
from firebaseui-ios.
from firebaseui-ios.
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?
from firebaseui-ios.
@kermankohli
As my sectioning fork is currently...
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 NSSortDescriptors
), it will sort first by the zeroth sort descriptor, then the first, and so on. The sort descriptor queries the snapshot. So you could do:
@[[[NSSortDescriptor alloc] initWithKey:@"value.origin_date" ascending:NO]];
This will order by the origin_date
child of the snapshot, with the largest value at the top.
or
@[[[NSSortDescriptor alloc] initWithKey:@"key" ascending:YES]];
This will order by the key
of the snapshot (the last key path of the ref).
You have to use a key path like value.name
to query the value.
Predicates work much in the same way. You set the predicate to an NSPredicate.
[NSPredicate predicateWithFormat:@"%K == %@", @"value.hidden", @NO];
Only snapshots with the child hidden
with a value of FALSE will be shown.
I hope that helps!
from firebaseui-ios.
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!
from firebaseui-ios.
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.
from firebaseui-ios.
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/)?
from firebaseui-ios.
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 tasks/$taskID
while putting other info in users/john/tasks/$taskID
or similar.
from firebaseui-ios.
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?
from firebaseui-ios.
Ah! I have something similar in my own app. You have to sort or fetch by
something in the snapshot.
In mine, I have a list of subscriptions with basically just a timestamp,
Boolean, and an id for the data it relates too. The predicate is based on
the Boolean, and the sort is based on the timestamp. Then I use another ref
to populate the cell.
from firebaseui-ios.
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)?
from firebaseui-ios.
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.
from firebaseui-ios.
Closing because pull #13 deals with this
from firebaseui-ios.
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.
from firebaseui-ios.
Related Issues (20)
- Facebook Dependency Update to 15.0.0 HOT 1
- How to use? HOT 2
- Update GoogleSignIn to version 7.0.0 to fix GTMSessionFetcher 3.x issue
- default email address not working for signup HOT 2
- `sd_setImage(with:maxImageSize:placeholderImage:options:completion:)` crashing the app when using `.progressiveLoad` HOT 1
- [Breaking] Auth.auth().useUserAccessGroup not functioning in iOS 16 HOT 2
- visionOS platform support
- [Phone Auth] Building with Xcode 14.3.X, displays wrong country code HOT 5
- Please support Facebook SDK 16+ HOT 2
- Update documentation to describe how use it with SPM HOT 3
- The FIRUser displayName appears empty when using 'Sign in with Apple'
- Multiple user creation requests on Firebase when user repeatedly taps the Save button HOT 1
- Cannot login using Firebase UI HOT 2
- FUIAnonymousAuth - Missing ProgressView causing simultaneous auth attempts HOT 1
- Login with existing email/password account issue. HOT 1
- Enable email enumeration protection HOT 1
- Privacy manifest required by Apple HOT 1
- SPM - Facebook SDK version range outdated (..<"16.0.0") HOT 2
- Dependency GoogleSignIn need privacyInfo?
- Cannot assign value of type 'AppDelegate' to type '(any FUIAuthDelegate)?' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebaseui-ios.