gia*_*ise 0 javascript mongoose node.js
当我尝试定义架构时出现此错误。
错误:
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)
Run Code Online (Sandbox Code Playgroud)
架构:
export const albumSchema = new Schema({
id: {
spotify: String
},
tags: [{ type: Schema.Types.ObjectId, ref: "Tag" }],
}, { timestamps: true });
Run Code Online (Sandbox Code Playgroud)
引发错误是因为我有一个名为的字段id可能会覆盖内部_id字段。
我决定更改我的架构:
export const albumSchema = new Schema({
publicId: {
spotify: String
},
tags: [{ type: Schema.Types.ObjectId, ref: "Tag" }],
}, { timestamps: true });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2650 次 |
| 最近记录: |