📜  猫鼬虚拟填充不起作用 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:22.440000             🧑  作者: Mango

代码示例1
// virtual pupulate
AuthorSchema.virtual('posts', {
  ref: 'BlogPost',
  localField: '_id',
  foreignField: 'author'
})

// add this in your schema if vritual is not work, this method working for me
AuthorSchema.set('toObject', { virtuals: true })
AuthorSchema.set('toJSON', { virtuals: true })