Skip to content

Conversation

@premdood
Copy link

Summary
The Document class is derived from Modal class

The Document class is derived from Modal class
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes you think this is a typo? In Mongoose, Model inherits from Document:

mongoose/lib/model.js

Lines 116 to 128 in 0c5f56f

function Model(doc, fields, skipId) {
if (fields instanceof Schema) {
throw new TypeError('2nd argument to `Model` constructor must be a POJO or string, ' +
'**not** a schema. Make sure you\'re calling `mongoose.model()`, not ' +
'`mongoose.Model()`.');
}
if (typeof doc === 'string') {
throw new TypeError('First argument to `Model` constructor must be an object, ' +
'**not** a string. Make sure you\'re calling `mongoose.model()`, not ' +
'`mongoose.Model()`.');
}
Document.call(this, doc, fields, skipId);
}

@premdood
Copy link
Author

After looking into this further, I realised this isn't actually a typo. The documentation is correct as written. Model inherits from Document by calling the Document constructor.
Apologies for the confusion.

@premdood premdood closed this May 31, 2025
@premdood premdood deleted the patch-1 branch May 31, 2025 10:18
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 this pull request may close these issues.

2 participants