Show HN: FilterQL – A tiny query language for filtering structured data (github.com)
Hey all, I just released v2.0.0 of FilterQL, a query language and TypeScript library. This version adds support for Operations, which allow you to transform the data after filtering.
If you think this would be useful in a project you're working on, give it a try and let me know what you think!
17 comments
[ 3.0 ms ] story [ 48.3 ms ] threadAny intended support for collections/sets? In JQL is do ‘“foo” not in (“evil”, “silly”)’ or similar matchers over sets, like if tags are on a ticket or if tickets an in an N states
If you're talking about a query where you want "foo" to not be "evil" OR "silly", you could write 'foo != evil || foo != silly'.
There's a separate case where the value itself is an array/collection/set, in which case doing anything with that is currently unsupported. Values can only be strings, numbers, or booleans.
[1] https://github.com/adamhl8/inspectarr
``` const recentGoodMovies = filterql .filter(movies, "year >= 2008") .sort("rating") .desc()
```
If adding helper methods for semantics and clarity is not the intent of the library, then I'd rename the `filter` method since it doesn't communicate the intention clearly.
The function executes a full pipeline filter expression + `|` operations like `SORT` and `LIMIT` (not just a predicate filter). So for instance naming it to `query` will match your README terminology and grammar (`query := filter | operation*`)
You're right though, the naming of the `filter` method is confusing. I need to split off the filtering and applying of operations into two separate methods. And probably provide an additional `query` method like you said which would do what `filter` is doing now. Appreciate the feedback!
I wonder if there is a good birds-eye FAQ/HOWTO/overview of all the existing (families) of query languages. Just to systematize Datalog, GraphQL, SQL, there are tons of them.
[1]: https://github.com/gritzko/go-rdx
It offers nested filtering out of the box. All feature-packed in a lightweight package.
[1]: https://github.com/bouyguestelecom/spl [2]: https://github.com/BouyguesTelecom/SPL/blob/main/src/antlr/S...
[1]: https://github.com/nicolaspasqualis/go-fq