Skip to content
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

DocumentArray.discriminator return type #8287

Closed
hasezoey opened this issue Oct 28, 2019 · 1 comment
Closed

DocumentArray.discriminator return type #8287

hasezoey opened this issue Oct 28, 2019 · 1 comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@hasezoey
Copy link
Collaborator

Do you want to request a feature or report a bug?

docs / bug

What is the current behavior?

no return type is documented in https://github.com/Automattic/mongoose/blob/master/lib/schema/documentarray.js#L153

and it does not return an instance of mongoose.Model (what @types/mongoose suggests it does)

If the current behavior is a bug, please provide the steps to reproduce.

look at the documentation, and model.discriminator returns a model and DocumentArray.discriminator returns an constructor (that is not a model)?

What is the expected behavior?

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

mongoose: 5.7.7
node: 12.13.0
mongo: 4.2-bionic (docker)

@vkarpov15
Copy link
Collaborator

I think there's some misunderstanding here. Model.discriminator() returns a model class (a class that inherits from mongoose.Model), not an instance of a model class. You're right that DocumentArray.discriminator() returns a constructor that is vaguely similar to a model.

I added a note to the docs about the return types.

@vkarpov15 vkarpov15 added this to the 5.7.8 milestone Nov 3, 2019
@vkarpov15 vkarpov15 added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

2 participants