matt
matt
PPrisma
Created by matt on 10/7/2024 in #help-and-questions
Are Prisma queries parameterized to prevent SQL injections?
I was just reading about parameterized queries today and I was wondering does Prisma use parameterized queries under the hood to prevent SQL injections? I tried searching the docs for info about this, but could only find info about writing raw queries that are parameterized (which is not what I am trying to do)
8 replies
PPrisma
Created by matt on 4/7/2024 in #help-and-questions
How to use enum?
I'm using Next.js and TypeScript for my project, but I'm getting an error when I attempt to call prisma create. Error: Type 'string' is not assignable to type 'Status | undefined'.ts(2322)
// page.tsx
const [name, setName] = useState('');
const [company, setCompany] = useState('');
const [status, setStatus] = useState('Applied');

async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
const result = await prisma.job.create({
data: {
name: name,
company: company,
status: status.toLocaleLowerCase(), // Error: Type 'string' is not assignable to type 'Status | undefined'.ts(2322)
},
});
}
// page.tsx
const [name, setName] = useState('');
const [company, setCompany] = useState('');
const [status, setStatus] = useState('Applied');

async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
const result = await prisma.job.create({
data: {
name: name,
company: company,
status: status.toLocaleLowerCase(), // Error: Type 'string' is not assignable to type 'Status | undefined'.ts(2322)
},
});
}
// schema.prisma
model Job {
id Int @id @default(autoincrement())
name String
company String
status Status @default(APPLIED)
}

enum Status {
OFFERED
REJECTED
APPLIED
PENDING
}
// schema.prisma
model Job {
id Int @id @default(autoincrement())
name String
company String
status Status @default(APPLIED)
}

enum Status {
OFFERED
REJECTED
APPLIED
PENDING
}
Does anyone know how to resolve this error? It looks like I need to use the enum instead of a string, but I'm not sure how to do that
15 replies