施放到objectId失败了value \&quort \&quot (键入字符串)在路径上\&quort'cattory \&quot'因为\&quot'bsontypeerror \
在&添加类别显示错误时。
const mongoose = require(“ mongoose”); const {objectid} = mongoose.schema;
{
类别: { 类型:objectid, 参考:“类别”, },
};
除类别外,每个细节都在MongoDB表中添加
I have the Cast to error in JSON response when Adding the Product Details in the & when adding category showing Error.
const mongoose = require("mongoose");
const { ObjectId } = mongoose.Schema;
{
category: {
type: ObjectId,
ref: "Category",
},
};
Except category Every detail is adding in the mongodb table
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该尝试mongoose.schematypes.objectid
,如果您试图与_id汇总,以便您应该尝试
You should try mongoose.SchemaTypes.ObjectId
And if you are trying to aggregate with _id so you should try