Skip to content

Instantly share code, notes, and snippets.

@keizie
Created February 12, 2025 12:04
Show Gist options
  • Save keizie/7437092099cfd215391a55742d3b643d to your computer and use it in GitHub Desktop.
Save keizie/7437092099cfd215391a55742d3b643d to your computer and use it in GitHub Desktop.
nest.js service from prisma $extends (type 2) variant
constructor() {
super()
const ext = Prisma.defineExtension((client) =>
client.$extends({
name: 'webinarAfterCreate',
query: {
webinar: {
async create({ args, query }) {
console.log('webinarAfterCreate', args)
const result = await query(args)
console.log(result)
// afterCreate logic
console.log(
await client.topBanner.create({
data: {
title: faker.commerce.product(),
url:
'https://papago.naver.com/' +
result.title,
},
}),
)
return result
},
},
},
}),
)
Object.assign(this, new PrismaClient().$extends(ext))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment