我有一個集合包含數據:
{
"_id" : ObjectId("51dfb7abe4b02f15ee93a7c7"),
"date_created" : "2013-7-12 13:25:5",
"referrer_id" : 13,
"role_name" : "Physician",
"status_id" : "1",
}
我送查詢:
cmd {
"mapreduce" : "doctor" ,
"map" : "function map(){emit(this._id,this);}" ,
"reduce" : "function reduce(key,values){return values;}" ,
"verbose" : true ,
"out" : { "merge" : "map_reduce"} ,
"query" : { "$where" : "this.demographics.first_name=='makdoctest'"}
}
我得到的錯誤爲:
"errmsg" : "exception: count failed in DBDirectClient: 10071 error on invocation of $where function:\nJS Error: TypeError: this.demographics has no properties nofile_a:0"
這意味着,在您的文檔的一個地方'demographics'是'null'或不存在,你需要首先做一個空檢查,但更多的importsantly你爲什麼這個洞在$那裏,它就像你第3次濫用$ where操作符 – Sammaye
@Sammaye爲什麼發表評論,請將其作爲答案 –
你爲什麼使用'$ where'?這是緩慢和難以閱讀和維護。 –