Find a value in json object using lodash methods flatten and find -


using lodash want find team id 3229. tried following not returning anything.

    var team = _.chain(data.teams)         .flatten("divisionteams")         .find({"id":3229})         .value(); 

here plunker code.

http://plnkr.co/edit/udwzrkx3zkyjyf8uwo7i

for json data please see file data.js in plunker.

please note cannot change json data since calling test api.

flatten doesn't take argument, see docs. need either map or pluck divisionteams.

_.chain(data.teams) .pluck('divisionteams') .flatten() .find({id: 3232}) .value(); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -