Filtering multiple value with multiple key in json array using lodash

后端 未结 3 1293
一向
一向 2021-02-10 18:01

i have a dynamic data each time there could be dynamically different key value pair to be filtered in different data. how can we filter it with multiple key,value in lodash. i w

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-10 18:57

    _.filter method doesn't allow you to specify multiple options for filtering. Try with passing custom filter function:

    _.filter(data, function (item) {
      return ['REPUBLICAN', 'DEMOCRAT'].indexOf(item.PARTY) >= 0
          && ['PERM', 'POLL'].indexOf(item.BALLOT_STATUS) >= 0
    })
    

提交回复
热议问题