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

Cannot provide the 'fields' parameter for a 'gin' index for JsonB column type

Open WrRaThY opened this issue 3 years ago • 2 comments

Issue

Cannot provide the 'fields' parameter for a 'gin' index

Versions

2.1.3

  • sequelize: 6.17.0
  • sequelize-typescript: 2.1.3
  • typescript: 4.3.5

Issue type

not sure, but...

  • [] bug report
  • [x] feature request

Actual behavior

no way to define inner field to create an index on for a json b column using a gin index

Expected behavior

According to sequelize docs (https://sequelize.org/docs/v6/other-topics/indexes/) I should be able to specify fields parameter. I understand that this if provided using annotations on top of a field, but in case of gin indexes - it might not be enough. What I mean by that is that my JSON doesn't have to be an array - an array can be nested inside an object, like this:

{
  "field": "value",
  "arrayField": ["val1", "val2"]
}

It would be great to be able to set this the same way as you can set it using SQL itself, for example:

CREATE INDEX gin_idx ON "TestTable"
    USING gin (("jsonBColumn"->'arrayField') jsonb_path_ops);

Steps to reproduce

just lack of definition options

Related code

already pasted above

WrRaThY avatar Apr 22 '22 01:04 WrRaThY

This seems to be a feature request for sequelize rather than sequelize-typescript, consider opening one in our repository instead

ephys avatar Apr 25 '22 04:04 ephys

as I mentioned in the description - this feature already exists in sequelize itself (I linked docs)

WrRaThY avatar Apr 25 '22 09:04 WrRaThY