async listProduct({ type, origin, name, order }: IProductFilterDTO): Promise<ProductEntity[]> {
const where: Prisma.ProductWhereInput = {};
if (name) where.name = { contains: name, mode: "insensitive" };
if (type) where.type = { contains: type, mode: "insensitive" };
if (origin) {
where.nativeFrom = {
hasSome: [ origin ]
};
}
const orderByOptions: Prisma.ProductOrderByWithRelationInput = {
name: order === 'desc' ? 'desc' : 'asc',
};
const products = await this.repository.product.findMany({
where,
orderBy: [orderByOptions]
});
return products;
}
In this code above i am trying to filter a substring inside the field “nativeFrom” using “contains” like i successfully did with the other simple string fields “name” and “type”, but prisma does not allow to use it inside “hasSome”. It seems that it was possible in old versions, but now it has changed. How can i achieve this?
In the first place, thank you all for the attention.
I’ve tried to use contains inside “hasSome”, “HasEvery” or similar ones but it is not possible anymore.