-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Referenced documents do not have id #1263
Comments
Thanks for posting this! I'd posted on the Vue Discord last night hoping to get an answer as to what I was doing wrong that useDocument was giving me the content of the referenced items but not the actual ID. |
Note that if you only want the id, you can use |
Yeah, I want both, though. The use case I was describing on the Discord is something like this:
|
I recommend to fix it this way vuefire/src/firestore/utils.ts Line 101 in ae85a41
|
yeah, that would be one way. I think we could also have an option for this that allows to use any custom converter and that by default uses the default converter. What do you think? |
Sorry, I mean Providing custom converter per dependency could also be nice. In my head a solution could be additional {
"converter": commentConverter,
"$user": {
"converter": userConverter,
"$roles": {} // instructs to expand with default converter
}
} Not mentioned fields should not be expanded. I use $ prefix for actual document fields. |
The converter will likely be passed as an argument to be able to use local options. I think that instead, allowing both the converter object and a function that returns a converter based on the ref or useDocument(..., {
refConverter: customConverter
})
useDocument(..., {
refConverter: (docRef) => docRef.id.includes(...) ? false : customConverter
}) |
Sure, that could work as well. Could you please implement the use of |
Unfortunately it will have to wait a bit. Use https://www.npmjs.com/package/patch-package and locally patch the package in the meantime, it should be pretty straightforward. v2 didn't have this behavior either |
Thanks for recommendation. I use 2.2.5 and it gives |
Just popping back to say patch-package with donatas-luciunas's original suggestion worked like a dream. |
hey @posva or @donatas-luciunas i just popped in with the same problem, i simply cant get the id in my resolved reference: const coll = collection("projects").withConverter(globalFirestoreOptions.converter) should be enough i guess, to have all subsequent calls to what am i missing here? |
nvm, i found it (as it says in the doc, the |
Reproduction
N / A
Steps to reproduce the bug
Use
useDocument
for a document that has at least one referenceExpected behavior
Referenced document has
id
propertyActual behavior
Referenced document does not have
id
propertyAdditional information
I guess the fix should be somewhere here
vuefire/src/firestore/bind.ts
Line 123 in ae85a41
A default converter should be added for
refs
here.The text was updated successfully, but these errors were encountered: