I'm making a search by tags function, in a table like this
CREATE TABLE permission (
id serial primary key,
tags varchar(255)[],
);
Then I add a row that has the tags "artist" and "default".
I'd like to query it by tags (using the knex query builder), so if I do this:
async getByTags(tags: string[]): Promise<PermissionTable[]> {
return this.db<PermissionTable>('permission')
.select('*')
.whereRaw("tags @> '{??}'", [tags])
}
That produces the following statements depending on how many tags you passed.
This works
select * from "permission" where tags @> '{"artist"}';
This doesn't (returns an empty array, when it should the row I'm looking for)
select * from "permission" where tags @> '{"artist", "event"}';
Why does the one with multiple tags not work?