nestjs-query
nestjs-query copied to clipboard
Prisma Integration
Prisma is an open source next-generation ORM. Currently, it is not officially integrated with the nestjs-query package. It would be nice and easier for developer to use if we could get some official integration.
Have you read the Contributing Guidelines?
Yes
Describe the solution you'd like Integration for Prisma ORM
Additional context Ofcourse I don't expect full integration in one night. But a small start would be very nice. I'm not know much thing yet, but I'm happy to help if u need it.
Could be interesting to add! But to much work for myself as I also don't use / have a project using Prisma.
We were willing to tackle building a Prisma adapter for Nestjs-Query so deeply looked into this. The bottom line is that it's just not possible with Prisma as it stands. The generated code does not emit the metadata needed at runtime in order to enable such an adapter. We ended up rolling a Prisma code generator to generate TypeORM definitions based on our Prisma schema. It wasn't pretty, but it saves us from having to write hundreds of entity classes and keeps up with ongoing changes a lot easier.
Interesting @dvins, I myself now also started using Prisma in a project and wonder: would something basic not work if we only go based on the metadata nestjs-query itself collects for relations?
I think the non relations should not be an issue right? Since you would already need to decorate each field.
We could also, if more info is needed expose @Field
/@FilterableField
ect from the Prisma adapter package so we can add additional fields the adapter could handle it correctly.
I've been spending on time on this topic, currently using nestjs-prisma-generator instead. In my past experience, creating an abstract for prisma its rather hard because the generated types from the client is particular to the schema, and there isn't a low-level generic exposed.
There is multiple issues/community thread in prisma are tracking this as well. All end up using some form of generator to read prisma schema and generate boilerplate code instead.
I've been spending on time on this topic, currently using nestjs-prisma-generator instead. In my past experience, creating an abstract for prisma its rather hard because the generated types from the client is particular to the schema, and there isn't a low-level generic exposed.
There is multiple issues/community thread in prisma are tracking this as well. All end up using some form of generator to read prisma schema and generate boilerplate code instead.
Spot on, the metadata (outside of the Prisma schema) just does not exist to do this.