Can't get Mongoose virtuals to be part of the result object
Because you're using JSON.stringify
in your console.log
call, that invokes the toJSON
method on the model instance, not toObject
.
So either omit the JSON.stringify
in your call:
console.log(results[0]);
Or set the toJSON
option on the schema like you're currently setting the toObject
option.
...{ toObject: { virtuals: true }, toJSON: { virtuals: true }});