var groupSchema = new Schema({ name:{type:String,unique:true}, paramlist:[{ name:{type:String,unique:true}, alias:String, ucl:Number, lcl:Number, unit:String, type:String }], createdate:{type:Date,default:Date.now}, createuser:{ type:mongoose.Schema.Types.ObjectId, ref:‘loginModel’ }
}); var group = mongoose.model(‘groupModel’,groupSchema);
module.exports = group;
这是数据模型, var array = new Array(); array.push({name:‘alt’,alias:‘ALT’,ucl:50,lcl:10,unit:'IU/L '}); array.push({name:‘ast’,alias:‘AST’,ucl:50,lcl:10,unit:‘IU/L’}); var json = { name:‘我的是1’, paramlist:array };
var ge = new group(json); ge.save(function(err){ log(err); });
这是保存方法,保存不成功!为什么 ,谢谢! 错误提示: message: 'Cast to Array failed for value "[ {