猫鼬模式路径的值无效

时间:2018-12-17 16:46:36

标签: node.js mongodb mongoose schema require

对于嵌入式架构,我收到以下错误消息。

抛出新的TypeError('模式路径' + prefix + key + '的无效值'); TypeError:架构路径disciplinedata.type

的值无效

disciplineinstance.js

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

const disciplineInstanceSchema = mongoose.Schema({
  estimateEffortunits: {type: Number, default: 0 },
  disciplineInstancename: {type: String, default: ''},
  majortasks: {type: [majorTaskInstanceSchema], default: [] },
  disciplinedata: {type: disciplineSchema }
});

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 disciplineSchema = mongoose.Schema({
  majortasklist: { type: [mongoose.Schema.Types.ObjectId], ref: 'MajorTask'},
  disciplinename: { type: String },
  disciplineunitname: { type: String },
});

module.exports.disciplineSchema = disciplineSchema;
module.exports = mongoose.model('Discipline', disciplineSchema);
module.exports.Discipline = mongoose.model('Discipline', disciplineSchema);

我已经尝试了多种方法来解决此问题。它必须与学科.js中的错误有关,但是我找不到错误。这些类型似乎很好,我无法解决实际需求。

0 个答案:

没有答案