I have an array of objects:
var results= [ { "_type": "MyType", "_id": "57623535a44b8f1417740a13", "_source": { "info": { "year": 2010, "number": "string", }, "type": "stolen", "date": "2016-06-16T00:00:00", "createdBy": "57469f3c71c8bf2479d225a6" } } ];
I need to select specific fields from an array. As a result, I want to get the following:
[ { "_id": "57623535a44b8f1417740a13", "info": { "year": 2010, "number": "string" }, "type": "stolen", "date": "2016-06-16T00:00:00", "createdBy": "57469f3c71c8bf2479d225a6" } ]
As you can see, I want to select the _id field and the contents of the _source object. How can I do this with lodash?
I found the .map function, but does not accept an array of keys: var res = _.map(results, "_source");
source share