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.

[Feature Request] Custom operators

See original GitHub issue

This feature allow developers to define new operators.

For example:

  1. define a new operator json_contains template
(alias, values)=> `JSON_CONTAINS(${alias}, ${values})`
  1. use like filter=roles||json_contains||ROLE_A,ROLE_B
  2. generate
andWhere('JSON_CONTAINS(roles, :roles)',{roles: JSON.stringify(roles)})

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
prevostccommented, Sep 15, 2020

If that helps, I was able to implement a custom operator by overriding mapOperatorsToQuery on the service

  protected mapOperatorsToQuery(cond: QueryFilter, param: any): { str: string; params: ObjectLiteral } {
    if (cond.field === "tags") {
      let str: string
      let params: ObjectLiteral = { [param]: cond.value }

      const field = this.getFieldWithAlias(cond.field)
      switch (cond.operator) {
        case "$cont":
          str = `${field} @> :${param}::jsonb`
          params = { [param]: `${JSON.stringify(cond.value)}` }
          break
        default:
          str = `${field} = :${param}::jsonb`
          break
      }
      return { str, params }
    } else {
      return super.mapOperatorsToQuery(cond, param)
    }
  }

This is a bit of a manual work, but it could be generalised. And it makes sense to override the service protected methods to add new functionality.

Maybe all that is needed is a “Custom operator” section on the wiki.

0reactions
rgoleacommented, Feb 5, 2020

@Diluka the PR I pushed would have fixed the problem (hopefully)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nim 2 feature request - Custom operators - Nim forum
I've run into times where a proc is most naturally expressed as an operator, for example, something like a signed modulus, or checking...
Read more >
Creating a custom Operator - Apache Airflow
Creating a custom Operator¶. Airflow allows you to create new operators to suit the requirements of you or your team. The extensibility is...
Read more >
Feature Request - Interconnected - Intercom
Really simple functionality request: The ability to duplicate articles. Case in point: I have 3 similar articles to write which will be shown...
Read more >
[Feature Request] Custom Text | Forum | Aximmetry
[Feature Request] Custom Text and fade time on Peekers. Studio Operators Composer. Back to Posts. When building visual control feedbacks e.g. with a...
Read more >
File a Feature Request - TechDocs - Broadcom Inc.
Do you have a great idea for functionality that currently does not exist in the ... Our feature request process allows Rally users...
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