-
Notifications
You must be signed in to change notification settings - Fork 56
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
Keep ID in document.data() #68
Comments
Hmm. So you have an additional field in your documents that are a copy of the For your side question, you should be able to do it in the same file, but not within the same |
Yeah it's a workaround, as the |
Hey @HauptmannEck, can you take a look at this PR and see if it works for your use-case? |
@sbatson5 Looks like a great solution that will solve for my usecase. |
Summary
The mocking system strips the
id
from the mockeddoc.data()
response. I would like it to keepid
in the resulting document.Basic example
Motivation
To allow us to search for a specific document within a
collectionGroup
we keep theid
of our document stored as anid
field in the document. So we need to have the mock not strip that out when returningdoc.data()
.Not sure if it should be an option on
mockFirebase
, automatic, or another field:ex.
{keepIds: true}
or{id: 'id-1', _id: 'id-1'}
,Side Question
It seems from my testing that each test file can only truly have 1
mockFirebase
as they override each other, is it true that if I want to test say, both getting a Full QuerySnapshot and an Enpty one, that I will need 2 test files? As you cannot set thedatabase
field per test.The text was updated successfully, but these errors were encountered: