节点猫鼬估计验证失败错误

时间:2018-12-17 14:31:52

标签: node.js mongodb mongoose schema

我从Mongoose节点服务获得的返回状态为500。错误如下:

“估算验证失败:纪律:由于值” [{{majorTasks:[],     学科数据:      {学科名称:“测试1”,        学科单位名称:“小时”,        majortasklist:[Array],        _id:“ 5c1422ffe0051d22accb56f6”,        __v:0},     学科实例名称:'测试',     EstimateEffortUnits:45}]“在路径“学科”上”

estimate.js的代码

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const { DisciplineInstanceSchema } = require('../models/disciplineinstance');
var ObjectId = require('mongoose').Types.ObjectId;


const estimateScheme = mongoose.Schema({
  estimatename: { type: String },
  summarytext: { type: String },
  scopetext: { type: String },
  disciplines:{type: [DisciplineInstanceSchema] }
});


module.exports = mongoose.model('Estimate', estimateScheme);

学科实例代码.js

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const { disciplineScheme } = require('./discipline');
const { majorTaskInstanceSchema } = require('./majortaskinstance');
var ObjectId = require('mongoose').Types.ObjectId;

const disciplineInstanceSchema = mongoose.Schema({
  disciplineData: {type: disciplineScheme },
  estimateEffortUnits: {type: Number, default: 0 },
  disciplineInstanceName: {type: String, default: ''},
  majorTasks: {type: [majorTaskInstanceSchema], default: [] }
});

module.exports.disciplineInstanceSchema = disciplineInstanceSchema;
module.exports.disciplineInstance = mongoose.model('disciplineInstance', disciplineInstanceSchema);

和学科.js ...

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
var ObjectId = require('mongoose').Types.ObjectId;

const disciplineScheme = mongoose.Schema({
  disciplinename: { type: String, default: '' },
  disciplineunitname: { type: String, default: 'Hours'},
  majortasklist: {type: [mongoose.Schema.Types.ObjectId], ref: 'MajorTask' }
});

module.exports = mongoose.model('discipline', disciplineScheme);
module.exports.disciplineScheme = disciplineScheme;

我已经检查了传入的数据,并认为它采用正确的形式强制转换为该模式。我似乎找不到演员表的问题。

[{majorTasks:[],     学科数据:      {学科名称:“测试1”,        学科单位名称:“小时”,        majortasklist:[Array],        _id:“ 5c1422ffe0051d22accb56f6”,        __v:0},     学科实例名称:'测试',     EstimateEffortUnits:45}]

没有其他文件因缺少所需文件而引发错误。我似乎无法弄清楚是什么导致了此错误。 MajorTask当前未生成,但不是必需的。

0 个答案:

没有答案