Node.js 未在猫鼬上显示的虚拟和填充
我做错什么了吗?我一直在尝试在派对上展示虚拟场景,我尝试了简单的虚拟场景,比如“标语”,只是为了验证一下。我也有填充问题。我有点讨厌这个,因为它没有给我任何错误或警告,我也不知道它背后发生了什么。有点令人沮丧Node.js 未在猫鼬上显示的虚拟和填充,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我做错什么了吗?我一直在尝试在派对上展示虚拟场景,我尝试了简单的虚拟场景,比如“标语”,只是为了验证一下。我也有填充问题。我有点讨厌这个,因为它没有给我任何错误或警告,我也不知道它背后发生了什么。有点令人沮丧 const mongoose = require('mongoose'); mongoose.set("debug", true); const partySchema = mongoose.Schema({ name: { type: St
const mongoose = require('mongoose');
mongoose.set("debug", true);
const partySchema = mongoose.Schema({
name: {
type: String,
required: [true, 'Please provide a party'],
unique: [true, 'Party already exists. Please try another party name'],
maxLength: [20, 'Party Name should be less than 20 characters'],
minLength: [4, 'Party Name should be greater than 4 characters']
},
slogan:{
type: String,
required: [true, 'Please provide a slogan'],
maxLength: [20, 'Party Name should be less than 20 characters'],
minLength: [5, 'Party Name should be greater than 5 characters']
},
createdAt:{
type: Date,
default: Date.now()
}
},{
toObject: {
virtuals: true
}
,toJSON: {
virtuals: true
}
});
partySchema.virtual('slogans').get(function () {
// use an ordinary function so you can get the "this"
return this.slogan
});
外部id不是ObjectId数据类型外部id不是ObjectId数据类型