shardex
shardex
PPrisma
Created by shardex on 7/19/2024 in #help-and-questions
property 'data' does not exist on args when using $extends
here's my model if it helps
model User {
id String @id @default(uuid())
username String @unique
email String @unique
password String
}
model User {
id String @id @default(uuid())
username String @unique
email String @unique
password String
}
4 replies
PPrisma
Created by shardex on 7/19/2024 in #help-and-questions
property 'data' does not exist on args when using $extends
I actually removed it and done it some other way, but it is a copy paste of the solution in the stackoverflow code:
const prisma = new PrismaClient().$extends({
query: {
user: {
$allOperations({ operation, args, query }) {
if (['create', 'update'].includes(operation) && args.data['password']) {
args.data['password'] = bcrypt.hashSync(args.data['password'], 10)
}
return query(args)
}
}
}
})
const prisma = new PrismaClient().$extends({
query: {
user: {
$allOperations({ operation, args, query }) {
if (['create', 'update'].includes(operation) && args.data['password']) {
args.data['password'] = bcrypt.hashSync(args.data['password'], 10)
}
return query(args)
}
}
}
})
4 replies