Created
February 12, 2025 12:04
-
-
Save keizie/7437092099cfd215391a55742d3b643d to your computer and use it in GitHub Desktop.
nest.js service from prisma $extends (type 2) variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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