deitch / searchjs

A library for filtering JavaScript objects based on a json SQL-like language, jsql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comparing between field names

xescuder opened this issue · comments

I have an array with elements like:

{
start:5
end: 6
}

There's any way to do a search in array (matchArray) to find all objects where {start:{gte:end}} or {start:{gte:end-1}} ?

I'm interested in doing that sort of things, and I think your library is great, but I need something like this.
Thanks!

So you want the search field to be relative to another field? Rather than {start: {gte: 5}} you want to check where the value of one field (start) is gte (or some other comparator) to another field?

Yes, exactly. That's what I need. I need also to check for example if (start gte end*0.75).

No support for it now, but no reason it couldn't be extended to do so. The comparisons take place entirely in this function. It would need to be extended to be able to handle field being not just an absolute value, but perhaps an object that could contain relative fields.

Would also need a way to change the syntax in the query.

Go for a PR?