question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is there a way to search an object instead of an array?

See original GitHub issue

I’m using normalizr to get an object with the ids as keys, so I can access specific items without iterating every time through the array. I’ve seen that fuse can be configured to return only the results ids, which is nice for my purpose. But then it does not take my nested object.

Example:

const collection = {
  135 : {
    name : 'foo',
    _id : 135
  },
  187 : {
    name : 'bar',
    _id : 187
  }
}

the search always returns an empty array 😦

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kriskcommented, Mar 7, 2016

Thanks @Artem-Schander 😃

Thinking more about this, it might worth implementing in the core lib.

1reaction
github-actions[bot]commented, Apr 3, 2020

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find a value in an array of objects in Javascript - Stack Overflow
const search = what => array.find(element => element.name === what);. And you can check whether the item was ...
Read more >
How to Search in an Array of Objects with Javascript
Searching in an array of objects can be done in Javascript using a loop, Array.find() or Array.findIndex() methods.
Read more >
Array.prototype.find() - JavaScript - MDN Web Docs - Mozilla
The find() method is an iterative method. It calls a provided callbackFn function once for each element in an array in ascending-index order, ......
Read more >
Javascript: How to find an object in an Array of objects
The first approach would be to find the array index of the search object using Array.findIndex(). Once the search index is found, we...
Read more >
Four Methods to Search Through Arrays in JavaScript
Learn about four approaches to searching for values in arrays: includes, indexOf, find, and filter methods.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found