Skip to content

feat(knex): Add support for extended operators in query builder (fixes #3377)#3578

Merged
daffl merged 2 commits intofeathersjs:dovefrom
michalgm:add-knex-extended-operators
May 3, 2025
Merged

feat(knex): Add support for extended operators in query builder (fixes #3377)#3578
daffl merged 2 commits intofeathersjs:dovefrom
michalgm:add-knex-extended-operators

Conversation

@michalgm
Copy link
Copy Markdown
Contributor

@michalgm michalgm commented Mar 21, 2025

This change adds the ability to define custom operators via a new extendedOperators option for the knex service constructor. This allows the use of database-specific operators that aren't included in the standard set.

  • Modified the knexify method to use both built-in and extended operators
  • Added documentation for the extendedOperators option
  • Added tests to verify the functionality with custom operators

Example usage:

const service = new KnexService({
  Model: db,
  name: 'people',
  extendedOperators: {
    $startsWith: 'LIKE',
    $fulltext: '@@'  // PostgreSQL full-text search
  }
})

This fixes #3377

This change adds the ability to define custom operators via a new
`extendedOperators` option for the knex service constructor. This allows the use of  database-specific operators that aren't included in the standard set.

- Modified the `knexify` method to use both built-in and extended operators
- Added documentation for the `extendedOperators` option
- Added tests to verify the functionality with custom operators

Example usage:
```typescript
const service = new KnexService({
  Model: db,
  name: 'people',
  extendedOperators: {
    $startsWith: 'LIKE',
    $fulltext: '@@'  // PostgreSQL full-text search
  }
})
@michalgm
Copy link
Copy Markdown
Contributor Author

I'm now realizing another approach would be to just extended OPERATORS to support everything the knex supports: https://github.com/knex/knex/blob/9bd12999907436c2ef51f786df09a9a7e8931cca/lib/formatter/wrappingFormatter.js#L9

@daffl daffl merged commit e260ca8 into feathersjs:dove May 3, 2025
2 checks passed
@daffl
Copy link
Copy Markdown
Member

daffl commented May 3, 2025

Thank you! This is a good step I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support additional postgres operators

2 participants