Mongoose Virtuals in MongoDB Aggregate

后端 未结 3 1057
有刺的猬
有刺的猬 2021-01-12 08:12

My Mongoose Schema is as follows:

var DSchema = new mongoose.Schema({
  original_y: {type: Number},,
  new_y: {type: Number},,
  date: {type: Date},
  dummy         


        
3条回答
  •  粉色の甜心
    2021-01-12 08:49

    This is an old question but I've come up with a useful hack to get back the virtuals and thought it might be useful for those searching for this problem.

    You can easily convert the objects back to mongoose models:

    documents = documents.map(d => {
      return new Document(d);
    });
    
    var virtual = documents[0].virtualProperty;
    

提交回复
热议问题