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.

Support IN queries

See original GitHub issue

Let’s say I have the following sample data:

[
  { id: 1, value: 'something' },
  { id: 2, value: 'something' },
  { id: 3, value: 'something' },
  { id: 4, value: 'something' },
  { id: 5, value: 'something' },
  { id: 6, value: 'something' },
  { id: 7, value: 'something' },
  { id: 8, value: 'something' },
  { id: 9, value: 'something' },
  { id: 10, value: 'something' },
]

When I execute the following:

let filtered1 = sample.filtered('id > 5')

it returns one Results object with 5 filtered values like this:

// value of filtered1 in console
Results {-1: undefined, Symbol(): 2, Symbol(): 8, Symbol(): "results"}

However, my question is how I can filter random ids? For example, I want to filter ids of 2, 4, 7, and 10. What I can think of is:

let filtered2 = [2,4,7,10].map( (id) => {
   return sample.filtered('id == $0', id);
})

But the problem here is it returns an array of 4 Results objects, not the single Results object.

// value of filtered2 in console
[Results, Results, Results, Results]

Is it possible to get the results like the filtered1 in the second case?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

20reactions
alaziercommented, May 20, 2016

Here is a code snippet that should generate the query you want to run:

var filtered = sample.filtered([2,4,7,10].map((id) => 'id == ' + id).join(' OR '));

This should create a query of the form id == 2 OR id == 4 OR id == 7 OR id ==10. Once we support IN queries it will do this for you internally.

15reactions
juanfer0002commented, Apr 23, 2019

Any update on IN operator?

Read more comments on GitHub >

github_iconTop Results From Across the Web

supports - CSS: Cascading Style Sheets - MDN Web Docs
The @supports CSS at-rule lets you specify CSS declarations that depend on a browser's support for CSS features. Using this at-rule is ...
Read more >
Support Query Definition - Law Insider
Support Query means your query for Technical Support via online form, e-mail or support phone line, filed by your Support Contacts or end...
Read more >
Our Top 5 Support Queries and How to Solve Them - GlobalSign
Our round the world team are ready to help you during local work hours and make sure your questions are solved almost as...
Read more >
Introduction to queries - Microsoft Support
A query can give you an answer to a simple question, perform calculations, combine data from different tables, add, change, or delete data...
Read more >
How @supports Works | CSS-Tricks
For example, iOS shipped support for CSS grid in version 10.2, ... in an article called Using Feature Queries in CSS a few...
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