安装新软件包mongoose-schema-extend 0.2.0后,运行gulp命令时出现以下错误:
C:\用户\ Artan \桌面\新-CT \ node_modules \猫鼬-架构延伸\ index.js:17 newSchema.callQueue.forEach(function(k){ ^
TypeError:无法读取属性' forEach'未定义的 在新的Schema.extend(C:\ Users \ Artan \ Desktop \ new-ct \ node_modules \ mongoose-schema-extend \ index.js:17:22)
安装mongoose-schema-extend后,我的模块如下所示:
'use strict';
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
BaseSchema = require('../../../../config/models/base_schema');
/**
* Partner Schema
*/
var PartnerSchema = new BaseSchema.extend({
name: {
type: String,
default: '',
required: 'Please fill Partner name',
trim: true
},
descr: {
type: String,
default: '',
required: 'Please fill Partner Description',
trim: true
},
user: {
type: Schema.ObjectId,
ref: 'User'
}
});
var Partner = mongoose.model('Partner', PartnerSchema);
module.exports = Partner;
答案 0 :(得分:0)
将var PartnerSchema = new BaseSchema.extend({
更改为var PartnerSchema =BaseSchema.extend({
并且有效。