猫鼬选择错误

时间:2018-08-25 14:25:44

标签: mongoose

我有一个像这样的猫鼬模式

    first_name          : String,
    other_names         : String,
    last_name           : String,
    gender              : String,
    title               : String,
employment      :{
        office              : String,
        location            : String
    },
    hobbies         :[{
        hobbied_id          : Schema.Types.ObjectId
    }],
    contact     :[{
        address             : String,
        city                : String
    }]

当我尝试通过我使用过的猫鼬从mongodb中提取信息时

Person.find({'exployment.office':'Greenway'})
    .exec(function(err, result){
        console.log(result);//<- this gives expected result 
        console.log(result.employment.office);//<- this produces error of undefined
        console.log(result.contact.address);//<- this produces error
    });

这将产生与在Greenway工作的所有人员有关的所有信息。 但是当我尝试从结果中获取特定细节时,会产生未定义的错误 请问我做错了什么,还有什么书或站点对学习猫鼬有用吗

0 个答案:

没有答案
相关问题