-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
This issue is for sharing thoughts on using prisma with loopback 4.
I wrote a simple example using prisma with loopback 4 and below are my initial observations.
-
Prisma does not work well with repositories, datasources or modals. The main reason for this is because prisma modals are tightly coupled with prisma datasources. This creates real friction with repositories, since repositories depend on a modal and datasource. I found it made the most sense to just directly use prisma in my controllers. The downside to this is that you cannot create loopback repository relationships with prisma data. Honestly though, that responsibility probably should lie with prisma anyways if you choose to use it.
-
The prisma api gets generated from prisma modals, which I find a bit awkward, although I understand it makes it easier to deal with the types. This will create challenges with loopbacks type system because loopback will be unaware of prisma types. This might be able to be improved with some hackery.
You can look at my example below.
https://github.com/codejamninja/lb4-prisma/blob/master/example/src/controllers/user.controller.ts