Skip to content

Conversation

@michalgm
Copy link
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
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
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