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

Support for virtual field #139

Open
vailancio opened this issue Mar 21, 2018 · 3 comments
Open

Support for virtual field #139

vailancio opened this issue Mar 21, 2018 · 3 comments

Comments

@vailancio
Copy link

I have a virtual field on my modal but it does not show up after I paginate.

@tzaborski
Copy link

tzaborski commented Dec 28, 2018

Maybe that's not super efficient but you can always do this to get virtuals. Keep in mind you have to set virtuals: true in the Schema toObject option.

Schema.paginate({}, { limit: 5 }).then(result => {
    for (let index in result.docs) {
      result.docs[index] = result.docs[index].toObject();
    }
    return result;
});

@leandrorazevedo
Copy link

leandrorazevedo commented Nov 28, 2019

in yours schema definition, set options like :

 {
    toJSON: { virtuals: true }
  }

@smallbzleads
Copy link

in yours schema definition, set options like :

 {
    toJSON: { virtuals: true }
  }

Thank you bro, saved my life :)

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

4 participants