I am using nest js with mongodb and for the mongodb modelling i am using Typegoose . they did not have autopopulate functionality yet.
I am using
https://github.com/szokodiakos/typegoose
and just want to use auto populate
https://www.npmjs.com/package/mongoose-autopopulate
There is an autopopulate
option for the prop
decorator, which is used like so:
import { prop, Ref } from '@typegoose/typegoose';
class Person {
@prop()
name: string
}
class User {
@prop({ autopopulate: true, ref: Person })
person: Ref<Person>;
@prop()
password: string;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With