Closed sbrichardson closed 5 years ago
Hah, yes that would be a problem. I think rare as well 😊. Could blacklist initialize
etc and do a runtime check in the constructor. I wonder which of these APIs people would like more:
// current
this.users.findOne()
// proposed
this.collection.findOne()
Replaced with this.collection
(or this.model
for mongoose): https://github.com/GraphQLGuide/apollo-datasource-mongodb/releases/tag/0.2.0
At first glance, it seems you could accidentally overwrite a class method or other info if a collection name matches an existing class property? Probably rare or I could also be wrong.
For example (haven’t tested) if you have a collection called “initialize”, “collectionName”, or “context” etc.
The constructor code referring to:
this[this.collectionName] = collection[this.collectionName]
If so, maybe storing it to a collection property etc?