如何将业务逻辑与棱镜逻辑分开
我刚刚开始在项目中使用Prisma作为ORM,但是我不确定如何将Prisma查询和逻辑代码与使用Prisma的服务逻辑分开,因为我们无法使用通用存储库方法,我希望为了找到实现这种脱钩的解决方法,有什么想法吗?
这是“应用程序”的一个示例。服务'使用Prisma
> async findByIdPrisma(applicationId: number):
> Promise<ApplicationModel> {
> const application = await this.prismaService.application.findUnique({
> where: { id: applicationId },
> });
> if (application) {
> return application;
> }
> throw new DataIsForbiddenOrNotFoundException('Application', {
> Application: applicationId,
> }); }
我想实现的解决方案是将这些查询作为函数在单独的存储库中具有完全与此服务完全解耦的功能,谢谢
I have just started using Prisma as an orm, in my project, but I am not sure how to separate the Prisma queries and logic code from the service logic that's using Prisma, since we can't use the generic repositories approach, I would like to find a workaround to achieve this decoupling, any ideas?
this is an example of an 'application. service' using Prisma
> async findByIdPrisma(applicationId: number):
> Promise<ApplicationModel> {
> const application = await this.prismaService.application.findUnique({
> where: { id: applicationId },
> });
> if (application) {
> return application;
> }
> throw new DataIsForbiddenOrNotFoundException('Application', {
> Application: applicationId,
> }); }
the solution that I want to achieve is having those queries as functions in a separate repository having it totally decoupled from this service, thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论