I'm trying to make a MikroOrm query in Typescript that gets all Movies which belong to a specified inputGenre. Each Movie has not one, but an array of genres associated to it. So if I have the following movies:
"Titanic" -> ["romance", "drama"]
"The Godfather" -> ["crime", "drama"]
"The Dark Knight" -> ["action", "crime", "drama"]
and I'm searching for all "crime" movies, I'm expecting to fetch "The Godfather" and "The Dark Knight". Here's how the Movie is defined:
@Entity()
export class Movie {
@PrimaryKey({ type: 'number' })
id: number;
@Property({ type: ArrayType })
genreList: string[] = [];
}
I've tried the below code, but it returns only the movies that have exactly one genre, equal to inputGenre
queryBuilder.where({ genreList: { $contains: [inputGenre] } });
What am I missing?