Prisma where clause 'startWith, endWith and contains' are not working.
Closed this issue · 2 comments
codewithmecoder commented
Environment
Node: Fastify
DB: MySql
ORM: Prisma
Prisma schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique /// @encrypted
emailHash String? @unique /// @encryption:hash(email)
name String?
password String
salt String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
expiredAt DateTime @updatedAt
products Product[]
}
Prisma Client
import { Prisma, PrismaClient } from "@prisma/client";
import { fieldEncryptionMiddleware } from "prisma-field-encryption";
const prisma = new PrismaClient();
prisma.$use(
fieldEncryptionMiddleware({
dmmf: Prisma.dmmf
})
)
export default prisma;
Service for making Prisma request
import prisma from "../../utils/prisma";
export async function findUserContains(str: string) {
return prisma.user.findMany({
where:{
email: {
contains: str,
}
},
select: {
email: true,
name: true,
id: true,
createdAt: true,
expiredAt: true
},
});
}
this return [] even if the string that pass is contained
github link: https://github.com/codewithmecoder/fastify-test
codewithmecoder commented
Ohh! I have read the docs it mentioned that is not possible.
But are you looking to that problem?
franky47 commented
But are you looking to that problem?
No. One possible solution to this problem would involve homomorphic encryption, which is years away from actual production-readiness.