redux-firestore
redux-firestore copied to clipboard
feat(doc) How to get the error from a query into the redux state
Hello,
I'm a little bit confused on how we can get the errors value stored in firestore.errors
as my queries are complex, with orderBy
and multiples where
the path to get it is really hard to implement. I've the same question on the request status, to know when something is fetched, maybe I've missed something in the documentation, but for know I can't find anything.
I've take a look at this function: https://github.com/prescottprue/fireadmin/blob/fc05a2a7e8a4036fa2b711c22d1c451f6241517c/src/utils/components.js#L108
But same problem, for example here the path where the errors are stored into my app:
requests?where=companyId,==,anID&orderBy=test
@magrinj Thanks for reaching out. I am thinking we might want to expose one of the utility functions in the current versions
That is what is done in the v1.0.0 pre-releases - they help loading out of state based on the query (since data is now stored that was as well).
Hi @prescottprue ! Thanks for your answer, from what I've read about this new version the utility function are only for ordered
and data
, it will be nice to have one for errors
and status
.
(The link in my first post was wrong, I update it !)
@prescottprue I took a look at the v1 roadmap and it seems like firestoreDataSelector
firestoreOrderedSelector
are going to be very helpful in this regard—thanks for adding those! Would also love to see selectors for errors
and status
as @magrinj mentioned at some point.
@magrinj if you still have this problem, I'm using the getQueryName()
function directly at the moment to convert my more complicated queries into strings that can be used to lookup the keys in firestore.data.requested
and firestore.data.requesting
etc..
If you end up doing this too, one thing to note is that the strings for requesting
and requested
can be slightly different for ?where=
parameters, e.g. notice the /
vs .
:
// in redux store:
firestore:
status:
requesting:
spaces?where=roles/1VGmFPZVr8ZsYduAM4CfKmrXZ1v2,in,owner,editor,viewer
requested:
spaces?where=roles.1VG1VGmFPZVr8ZsYduAM4CfKmrXZ1v2,in,owner,editor,viewer