Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set lean default with typegoose #72

Open
minefujiko9293 opened this issue Feb 22, 2024 · 1 comment
Open

how to set lean default with typegoose #72

minefujiko9293 opened this issue Feb 22, 2024 · 1 comment

Comments

@minefujiko9293
Copy link

image

In typegoose,
i want to no typing '{ virtuals : true }' but plugin can auto lean it.
when i use the mongooseLeanDefaults, i can use

@plugin(mongooseLeanDefaults as any, { defaults: true })
@plugin(mongooseLeanVirtuals as any, {
  enabledByDefault: true,
  virtuals: true,
  lean: true,
})
export class SyncBBRecord{
 @prop({ default: 'default_name' })
  name?: string;

  get vv() {
    return 'vv';
  }
}

const result = await this.mSyncBBRecord.findOne({}).lean();
console.log(result.name); // name has default value.
console.log(result.vv); // vv is virtuals.

the mongooseLeanDefaults plugin can auto lean,
but mongooseLeanVirtuals cannot.

i hope mongooseLeanVirtuals can esay use just like use mongooseLeanDefaults .

@minefujiko9293
Copy link
Author

minefujiko9293 commented Feb 22, 2024

Okay, it turns out that the NPM package is not synchronized with the git warehouse.
please republish the npm mongoose-lean-virtuals.

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

No branches or pull requests

1 participant