-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: useConnection(connection) function
#14802
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
vkarpov15
left a comment
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.
More testing required. Also please add TypeScript type definition and TypeScript test please
| this.db = connection; | ||
| const collection = connection.collection(this.modelName, connection.options); | ||
| this.prototype.collection = collection; |
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.
I believe this makes it such that the name of the collection is always set to the modelName which would be different from the name of the collection assigned initially, which could either be a user-defined collection name or one that is automatically generated by mongoose using the utils.toCollectionName as mentioned here: https://mongoosejs.com/docs/api/connection.html#Connection.prototype.model().
This leads to the case where a new collection is created and used once useConnection is invoked on the model. Is that intentional?
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.
That's a good point @meshde-flux , I will open up new issue
No description provided.