-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add listDocuments to collection #133
base: master
Are you sure you want to change the base?
Conversation
Bump. Can we get this merged in? |
Hi @joelpoloney, this repo is no longer used (see #160) and we will be publishing new releases from my fork until we land on a permanent way forward. I've opened a new PR over there with this change. We are also looking for maintainers. |
Oh! So sorry to hear :( Thank you for the update! I ended up forking it and support a few other use-cases as well: https://github.com/timbersoftware/firebase-mock/commits/master. Once your fork becomes the new source of truth, I can submit some PRs to you with the changes I made. |
Thanks, I'd be very grateful. I should become owner of the NPM name on or about 1 December and I'm looking to publish a minor version very soon after. So if you can open any PRs before next Thursday (Thanksgiving in the U.S.), that would give you the best chance of getting into the release. We're all very grateful, I'm sure, for the quality package Bryan left us. Marrying all of our different forks and carrying on his work would be a great way to say thank you. |
Ok great! I can try to open the PRs for you before Thanksgiving. Some are easy to open... others are me hacking away at the code to fix a bug but probably isn't the best long term fix. |
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.
This is going to require some doing.
As @op pointed out, this API is only available through firebase.admin.firestore
and not through firebase.firestore
. We need to test the different import paths and make sure they each have the correct behavior.
I've been looking at our code base and it looks like we don't actually have any example yet of firebase.admin
imports behaving differently from firebase
imports. One idea would be to extend the prototype in the admin
package and export it with the same name.
Any ideas?
db.collection('group').listDocuments().then(function(refs) { | ||
expect(refs.length).to.equal(1); | ||
refs[0].get().then(function(doc) { | ||
expect(doc.data().name).to.equal('test'); |
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.
Let's just go all the way and check for deep equality here.
expect(keys).to.contain(ref.id); | ||
}); | ||
done(); | ||
}).catch(done); |
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.
Isn't this going to silently swallow exceptions that occur before any assertions are run and give us a false pass?
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.
Good question. Mocha's done
accepts an error argument, so this should work as intended. https://mochajs.org/#asynchronous-code
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.
We're going to punt the issue of admin versus regular SDK to version 4. Merging.
This adds support for the
listDocuments
method toCollectionReference
.I need this when calling firestore from a service and not from a client. When preparing this PR I realised that this method only exists in the
firebase-admin
package and not in thefirebase
package. How have you dealt with differences like this before?References: