profile
viewpoint

Ask questionsUsing typegoose causes requests to stay at pending

<!--

  • In Versions, only include the Typegoose version you use (NPM or from GIT)
  • in "Code Example" add as many code blocks as needed, but when possible try to use an repo / gist
  • in "Do you know why it happenes replace the "no" if you know why -->

Versions

<!--If Possible, please try to use the latest versions-->

<!--"0.0.0" means it is not used / unknown-->

  • NodeJS: 12.4.1
  • Typegoose(NPM): 6.4.0 <!--Please confirm that the verison is 6.0.x or above-->
  • Typegoose(GIT): commithash
  • mongoose: 5.9.2
  • mongodb: 3.4.16-26-g315d49ee78

What is the Problem?

<!--Please add an description of what the bug / problem is--> I recieved many warnings like this when I use Typegoose

"mongoose: the method name "populated" is used by mongoose internally, overwriting it may cause bugs. If you're sure you know what you're doing, you can suppress this error by using schema.method('populated', fn, { suppressWarning: true })"

I don't know if these warnings are the cause of the problem that all requests will stay at pending after running a while my node server.

I hope you can solve the problem

Code Example


@modelOptions({schemaOptions: {versionKey: false, timestamps: true}})
export class Person extends Document {
    @prop({required: true})
    name?: string;
    @prop()
    number?: string;
    @prop({required: true})
    id?: string;
}

@modelOptions({schemaOptions: {versionKey: false, timestamps: true}})
export class Signer extends Document {
    @prop({required: true})
    team_name?: string;

    @prop({required: true, ref: 'Person'})
    captain?: Ref<Person>;

    @prop({required: true})
    great_select?: number;

    @prop({required: true})
    small_select?: number;

    @prop({ref: 'Person'})
    teammate_one?: Ref<Person> | null;

    @prop({ref: 'Person'})
    teammate_two?: Ref<Person> | null;
  
}


const _Signer = getModelForClass(Signer);
const _Person = getModelForClass(Person);

export default {
    Signer: _Signer,
    Person: _Person,
};

Do you know why it happenes?

no

typegoose/typegoose

Answer questions ScreamZ

Never extends mongoose.Document, it makes that issue of pending.

We will write some doc about that with @hasezoey, just discussed about it on discord

useful!

Related questions

Typegoose &amp; Mongoose on client side - typegoose hot 1
Github User Rank List