Skip to content

How to programmatically create a new subdocument from outside document? #9076

Closed

Description

For example, the only way right now that is documented to create a subdocument is:

const Model = mongoose.model('MyModel', schema);
const obj = new Model();
const subDocument = obj.someSubSchema.create(); // <--

I think it might be nice to document, if possible, a way to create the subDocument without having to create an instance of the model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions