0

I have a collection like this, I need to unwind "myuser" object.

{"_id" : ObjectId("578508630420bec15ea9876c"),
   "current" : "selectCategory",
   "myuser" : {
    "_id" : "56c49c540d9e391243ce2752",
    "myoptions" : [ 
    {
        "id" : "jobs",
        "name" : "Emploi"
    }
    ],
    "mychannel" : "ussd",
    "mycreateDate" : "2016-02-17T16:14:12.899Z",
    "myemail" : "",
    "mygender" : "",
    "myhidemsisdn" : "no",
    "mylang" : "fr",
    "mylastUpdate" : "2016-02-26T11:32:29.786Z",
    "myyob" : -1
     },
    "userInput" : "continue",
    "ussdsession" : "303819320" }

I'm looking for a output like myuser :

["_id","myoptions","mychannel","mycreatedate","myemail","mygender","myhidemsisdn","mylang","mylastupdate","myyob"]

I can get the keys of the collection.But myuser is a nested object which has keys.Thanks in advance

Smutje
  • 17,733
  • 4
  • 24
  • 41
user2733125
  • 59
  • 2
  • 6
  • Related http://stackoverflow.com/questions/2298870/mongodb-get-names-of-all-keys-in-collection You just need to change the line `for (var key in this) { emit(key, null); }` to `for (var key in this.myuser) { emit(key, null); }` in the mapper function to adapt to your needs. – chridam Jul 28 '16 at 08:07
  • Thanks , I got the result – user2733125 Jul 28 '16 at 08:13

0 Answers0