gpt4 book ai didi

node.js - 无法获取鉴别器值mongodb nodejs

转载 作者:太空宇宙 更新时间:2023-11-04 01:23:02 25 4
gpt4 key购买 nike

在我的情况下,我无法获得我需要的值:

我的对象是这样的:

const ReportSchema = new Schema({
number: { type: Number, default: 1 },
})

const ReportProfile = Report.discriminator('ReportProfile', new Schema({
profile: { type: Schema.Types.ObjectId, required: true, ref: 'Profile' }
}))

我用这个方法调用我的对象:

return this.reportStore.findProfileReport({profile: contentId})

最佳答案

你错过了什么

const options = {
discriminatorKey: 'type',
timestamps: true
}

之后,将其添加到您的模型中,如下所示:

const ReportSchema = new Schema({
number: { type: Number, default: 1 },
}, options) // don't forget the option

关于node.js - 无法获取鉴别器值mongodb nodejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58582950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com