Skip to content

need to invoke a method on referenced collection before populate when using mongoose #82

Description

@DavidHuang2002

Before populating the referenced field with a collection, the referenced collection needed to be registered, currently, to do that, we run some find a method that has no consequence, otherwise, we can get a Model not registered error. It can be pretty confusing in code.

Screenshot 2024-02-10 at 4 43 50 PM Screenshot 2024-02-10 at 4 43 27 PM

I think the cause of this problem is that the a schema is only registed to a model when we first import it and invoke a method on it, which might not have happened when we run populate. I think can be fixed by running all model registration statement(like the following) when the server first starts.
Screenshot 2024-02-10 at 4 54 11 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions