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

Document.modelName type definition is string, but get undefined at runtime #12669

Closed
2 tasks done
shouchechengadv opened this issue Nov 9, 2022 · 0 comments · Fixed by #12682
Closed
2 tasks done

Document.modelName type definition is string, but get undefined at runtime #12669

shouchechengadv opened this issue Nov 9, 2022 · 0 comments · Fixed by #12682

Comments

@shouchechengadv
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.7.0

Node.js version

18.12.0

MongoDB server version

4.4.17

Typescript version (if applicable)

4.8.4

Description

Document.modelName type definition is string, but get undefined at runtime

Steps to Reproduce

Typescript Code

const Model = mongoose.model('Test', new Schema());

const doc = new Model();
console.log('doc.modelName', doc.modelName);

Output

doc.modelName undefined

Type Definition

class Document<T = any, TQueryHelpers = any, DocType = any> {
    /** The name of the model */
    modelName: string;
}

Expected Behavior

Remove Document.modelName type definition

lpizzinidev added a commit to lpizzinidev/mongoose that referenced this issue Nov 11, 2022
lpizzinidev added a commit to lpizzinidev/mongoose that referenced this issue Nov 12, 2022
vkarpov15 added a commit that referenced this issue Nov 12, 2022
fix(document): Set Document.modelName property in constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant