当我尝试定义架构时出现此错误。
Error:
node_modules/mongoose/lib/plugins/idGetter.js:12
schema.virtual('id').get(idGetter);
TypeError: schema.virtual(...).get is not a function
at module.exports (/Users/g.paradiso/dev/albumin-diet/node_modules/mongoose/lib/plugins/idGetter.js:12:26)
Schema:
export const albumSchema = new Schema({
id: {
spotify: String
},
tags: [{ type: Schema.Types.ObjectId, ref: "Tag" }],
}, { timestamps: true });
引发错误是因为我有一个名为id
这可能会覆盖内部_id
field.
我决定更改我的架构:
export const albumSchema = new Schema({
publicId: {
spotify: String
},
tags: [{ type: Schema.Types.ObjectId, ref: "Tag" }],
}, { timestamps: true });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)