0

I have a collection of the following :

{
  "_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"
  }
}

I am creating the following Map function:

"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}});"

as per the documentation , but I am getting the error

"errmsg" : "exception: couldn't compile code for: `_map`"
Chris Heald
  • 61,439
  • 10
  • 123
  • 137
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29

1 Answers1

0

Please try:

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
    }
  });
}

Inline:

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 } }); }
Pierre-Louis Gottfrois
  • 17,561
  • 8
  • 47
  • 71