-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Description
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
const schema = new mongoose.Schema({
some_field: Number,
}, {
toObject: { virtuals: true },
toJSON: { virtuals: true },
})
schema.virtual('test.a', function() {
return 1;
});
schema.virtual('test.b', function() {
return 2;
})
///
console.log(model.toJSON()); // don't see test object
{
some_field: 1
}
What is the expected behavior?
{
some_field: 1,
test: {a:1,b:1}
}
but when model.test.a
-> works, toJSON -> not
Please mention your node.js, mongoose and MongoDB version.
Mongoose: 4.11.3
NodeJS: 7.6.0
tankist
Metadata
Metadata
Assignees
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.