doug-martin/nestjs-query

[Question / Feature Request] Support for filterable array fields

Opened this issue · 7 comments

Is there any way to have a filterable array field? For example, I have a type/entity with an array of tags like so:

@Field(type => [String])
@Column('jsonb', { default: [] })
tags: string[]

If I change the @Field decorator to a @FilterableField decorator, it breaks with a TypeError: Cannot read property 'charAt' of undefined error. I assume this is because filterable array fields are not supported? I didn't find anything about it in the docs.

I would like to be able to query for records that contain a specific tag(s) within the tags array or that have a certain length of the tags array.

I'll have to look into how this could be supported, or how generic it could be I think this would depend on the dialect that is being used.

In postgres we could use jsonb but I'm unsure about others. If you have any suggestions I'd love to hear them.

Thanks!

I stumbled upon this one as well. In my case I am using it for phone numbers on contact. I am using Postgres as DB with a column type of text[]

Currently the attribute looks as follows:

  @Column({ array: true, type: 'text' })
  @Field(() => [String], { nullable: true })
  phoneNumbers: string[];

Hi!
Any progress on this topic? I am creating an API in the same line as the @amille14 example where the search by tags is very important since it is an API for a store. In my case I use MongoDB as a database with mongoose. In case of not being able to use @FilterableField, is there any other standardized alternative that allows searching by array field?

I am needing this as well. for mongoose/typegoose it is straightforward but I am not sure if it is easy(or feasible) for other SQL databases. Can someone setup a general plan for SQL part? I can help with the NoSQL/MongoDB part.

I guess its safe to say that not all dbs that TypeORM or sequelize support are able to work with array columns. When using TypeORM, you can use the simple-array column type to mitigate that, but I don't know how things are with sequelize. Does anyone have an idea there?

Face the same issue on my project. Are there any updates here?

Is this still an issue? Seems very strange that this is not supported since NestJs supports array fields