我想访问以下模型的所有字段:
CVSchema = new Schema({
name : {type:String,required:true},
fonction:{type:String,required:true},
agence:{type:String,required:true},
skills:[{type:String, ref:'Skill'}],
experiences:[{
agence:{type:String,required:true},
client:{type:String,required:true},
function:{type:String,required:true},
objectif:{type:String,required:true},
missions:[{mission:{type:String,required:true}}],
environements:[{type:String, ref:'Skill'}]
}]
}
现在,我使用它来获取属性
for (var property in CV.schema.paths){
if (CV.schema.paths.hasOwnProperty(property) && CV.schema.paths[property]["instance"] === "String") {
//my stuff here...
}
}
但问题是var属性只返回String,所以:name,function和agence,我想在技巧数组中包含所有String,或者在Experience.environements数组中包含String
希望你知道我的意思。
我尝试了一些代码,但它没有工作:(