sequelize-typescript icon indicating copy to clipboard operation
sequelize-typescript copied to clipboard

Utilizing Op.match with postgres

Open ticketbuyer opened this issue 3 years ago • 1 comments

Issue

Just looking for some pointers on how to use the Sequelize operator "match" with sequelize-typescript. I have indexes in place but when I query using [Op.match] first of all it doesn't appear to be available in any packages other than @sequelize/core ( using version ^7.0.0-alpha.10). When I change the import for Op to : import { Op } from '@sequelize/core/types';

all other operators that worked when importing through 'sequelize' no longer line up with the sequelize-typescript model definitions.

Any help/guidance is greatly appreciated!

Thanks, Jeff

Versions

  • sequelize: ^6.9.0
  • sequelize-typescript: ^2.1.1
  • typescript: ^4.3.5

Issue type

  • [ ] bug report
  • [x ] feature request

Actual behavior

ticketbuyer avatar Feb 27 '22 18:02 ticketbuyer

@sequelize/core is Sequelize 7, you need to use sequelize with Sequelize-TypeScript for now

Op.match can be used like this:

import { Op } from 'sequelize';

User.findAll({
  where: { name: { [Op.match]: fn('to_tsvector', 'myString') } }
})

it will result in

"name" @@ to_tsvector('myString')

ephys avatar Apr 07 '22 13:04 ephys