-
Couldn't load subscription status.
- Fork 2.2k
feat: introduce rtdb server-client caching (WIP) #1547
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @patrickmichalina! I'll let @jamesdaniels do more explaining, but we have an implementation for this planned that will take use of an internal SDK method. It will make it easier for the SDK to take over from transferred state.
|
@jamesdaniels @davideast Ok so there are a lot of concerns with this feature to address. After spending a great deal of time trying to work it out, it seems the most efficient way to handle this is to have a separate server side module/service that handles each database (rtdb/firestore) differently. Instead of using the client libraries (which have auth limitations, assumes localstorage of auth, sometimes hangs server reloads), we should use HTTP (or possible RPC) to perform the requests. In general I think only a subset of the features need to be supported on the server. Users are likely to only need to get/list their documents with the ability to query. This is actually pretty easy for RTDB, but more challenging for firestore since their libraries do not expose a method to convert queries to "structured queries" for the http POST. RTDB mostly complete implementation (even includes auth from current user via cookies): Firestore is not done, since I need to figure out the StructuredQuery situation :( Thoughts? |
|
hello, any update on this? |
|
Anyone want to comment on the approach we can take to authorize the current user on the server for firestore calls? RTDB is straight forward, but the complexity of firestore make me not want to right the REST wrapper just so I can set an auth token. |
|
can you explain current situation, as I know, RTDB is working with auth but firestore doesn't. |
|
@hiepxanh sure. RTDB The working code can be found here. I believe this to be a great solution for transferring state to the client + authorized requests. It would be nice if the initial client request was not made, but its handled with a Firestore It would be nice to simple use the client library on both server and client, but the auth situation is the issue with this. I can find no way to force a token to be used. It also wants to save the session in localStorage I believe? This is kind of an issue on the server. @jamesdaniels might have some knowledge here? |
|
Both working here: https://fusing-angular-pr-64.herokuapp.com/firebase But firestore is not using any queries and no auth is enforced in this example database (so you don't need to login to see the example) |
|
@hiepxanh you won't be able to login to that PR because it is a heroku review app and I have not enabled that domain on Auth0 :/, but I can assure you that works locally. |
|
Ok I see |
|
Going to close this PR, as I'm planning a different approach here. We don't want to go down the rabbit hole of mapping to http calls and having conditional behavior server/client. If you feel strongly about this being the correct approach for you, you may want to check out angularfire-lite. Thanks for the ideation and the work you put in here. I may source some of this change-set to bootstrap the state transfer work, if I do I'll make sure to credit you ;) |

Before going too far down the rabbit hole, I wanted to get feedback on the approach. So far this only accounts for READING from the cache (if it exists, once angular loads and takes over)