piotr-oles/rsql

`=contains=` operator for searching substrings

Closed this issue · 2 comments

Is your feature request related to a problem? Please describe.
I'm not able to search all rows from a column substring. I'm trying to look for a title that contains the word "test", but it's not possible. Only equal strings.

Describe the solution you'd like
It would be awesome to have some sort of operator like this claims RSQL supports those operators. I you have a guide or example for adding them I'd do it. Thanks.

Hi! :) You can add support for custom operators in your project by following this guide: https://github.com/piotr-oles/rsql#custom-operators .
So it would be:

// <your-project>/src/rsql/ast.ts
const CONTAINS = "=contains=";

export * from "@rsql/ast";
export { CONTAINS };

// <your-project>/src/rsql/builder.ts
import builder from "@rsql/builder";
import { CONTAINS } from "./ast";

export default {
  ...builder,
  contains(selector: string, value: string) {
    return builder.comparison(selector, CONTAINS, value);
  }
};

I'm closing it as there is no activity :)