0

我收集了以下内容:

{
  "_id" : ObjectId("51dfb7abe4b02f15ee93a7c7"),
  "date_created" : "2013-7-12  13:25:5",
  "referrer_id" : 13,
  "role_name" : "Physician",
  "status_id" : "1",
  "demographics" : {
    "date_created" : "2013-7-12  13:25:5",
    "first_name" : "jjjjkk",
    "last_name" : "jjjjkkjjjjkkjjjjkk",
    "birthdate" : "11-07-1980"
  }
}

我正在创建以下地图功能:

"map" : "function map(){emit(this._id,{demographics:{first_name\":this.demographics.first_name,middle_name\":this.demographics.middle_name,last_name\":this.demographics.last_name}});"

根据文档,但我收到错误

"errmsg" : "exception: couldn't compile code for: `_map`"
4

1 回答 1

0

请试试:

var map = function(){
  emit(this._id, {
    demographics:{
      first_name:  this.demographics.first_name,
      middle_name: this.demographics.middle_name,
      last_name:   this.demographics.last_name
    }
  });
}

排队:

var map = function(){emit(this._id, {demographics:{first_name: this.demographics.first_name, middle_name: this.demographics.middle_name, last_name: this.demographics.last_name } }); }
于 2013-07-31T07:10:33.560 回答