问题描述
collegeSchema.static("PostCollege",async function (body) {
try {
console.log(body);
let college = new School.discriminator("College",collegeSchema)({ body });
await college.save();
return college;
} catch (error) {
console.log(error);
}
});
MongooseError: `Model.discriminator()` cannot run without a model as `this`. Make sure you are not calling `new Model.discriminator()`
那么我应该如何编写这个以在模式静态中创建一个新的子模型?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)