-
Notifications
You must be signed in to change notification settings - Fork 153
Exporting all API types #123
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.
LGTM with a couple of nits
src/index.js
Outdated
@@ -1117,7 +1117,8 @@ validate = require('./validate')({ | |||
DocumentReference: reference.validateDocumentReference, | |||
ResourcePath: ResourcePath.validateResourcePath, | |||
}); | |||
WriteBatch = require('./write-batch')(Firestore, DocumentReference).WriteBatch; | |||
let batch = require('./write-batch')(Firestore, DocumentReference); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @type {Constructor} | ||
*/ | ||
module.exports.GeoPoint = GeoPoint; | ||
module.exports.FieldPath = FieldPath; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## master #123 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 1648 1661 +13
=====================================
+ Hits 1648 1661 +13
Continue to review full report at Codecov.
|
42ced1d
to
6404809
Compare
6404809
to
80e04de
Compare
@schmidt-sebastian, thanks for the quick response on this! I saw this from the SO question. Can |
ResourcePath is internal only and not intended to be part of the public API. We may change, rename or remove it at any point and hence exporting it is not an option for us at this point. Note that you might find this helper function useful for testing: https://github.com/googleapis/nodejs-firestore/blob/master/src/index.js#L350 |
@schmidt-sebastian, thanks. I took a quick look into that link, which led me to trying out For saving Firestore documents and later restoring them to the same or another Firestore project, one would need to maintain field type integrity. For The approach I took in the latest 1.2.1 version of https://www.npmjs.com/package/firestore-backup-restore was to drop |
I will talk to the rest of my team if we can provide better support for tools like yours. While we don't want end users to rely on the internals of our API, it makes sense for tools build on top of our clients. In the meantime, I have some suggestions for you: For one, you don't have to manually walk the hierarchy chain. You can directly pass ReferencePath.formattedName to firestore.doc() (doc() takes 'a/b/c/d' paths). Another option would be to call the snapshot_() function I mentioned and don't provide any data. That will get you a DocumentSnapshot whose DocumentReference you could use in your SDK. In general, the fewer private methods you end us using, the happier you will end up being (even if you have to go through more hoops). |
It looks to me like the So I forgot that Lastly, I finally was able to find the To conclude, I think storing the Thanks @stephenplusplus for all the info. It doesn't seem necessary anymore to expose |
You might find these tests useful if you need help with the private |
This PR exports all public types to allow end user to use them in their code directly, e.g. for instanceof checks.
b/72759064
https://stackoverflow.com/questions/48552183/how-to-get-firestore-documentreference-class