收到此错误:
Competition validation failed: results.0: Cast to ObjectId failed for value "{ name: 'David'}"
这是父母:
class Competition {
@prop()
compName: string
@prop({ ref: () => CompetitionParticipant})
results: Ref<CompetitionParticipant>[]
}
这是孩子:
class CompetitionParticipant {
@prop()
name: string
}
这是它的调用方式:
const CompetitionResults = getModelForClass(Competition)
await new CompetitionResults({compName: 'competition name', results: [{name: 'David'}]}).save()