Skip to content

Is a repository pattern with generics possible? #3929

Answered by ryands17
kevinvdburgt asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @kevinvdburgt 👋
Prisma is quite different from traditional ORM's in the case that it doesn't offser any way to inherit or extend methods as therer are no classes involved. You directly get the data in the form of a simple JavaScript object and not an instance of any class.

The example that you mentioned above, it unlikely with Prisma as you are trying to replace User with a generic. That would require a lot of efffort especially with TypeScript as it would need to know what data needs to be passed based on the model specified.

I have given a similar answer here on Slack which is quite similar to the pattern that you're following. Do give it a read and let me know if that answers your …

Replies: 11 comments 29 replies

Comment options

You must be logged in to vote
1 reply
@nikolasburk
Comment options

Answer selected by kevinvdburgt
Comment options

You must be logged in to vote
2 replies
@ryands17
Comment options

@mitsos1os
Comment options

You must be logged in to vote
3 replies
@josejavierpaez
Comment options

@FelipeCavichiolliSilvestre
Comment options

@Zebedeu
Comment options

Comment options

You must be logged in to vote
3 replies
@AlanMorel
Comment options

@webafra
Comment options

@AlanMorel
Comment options

Comment options

You must be logged in to vote
2 replies
@aislanspeedio
Comment options

@Gemy95
Comment options

Comment options

You must be logged in to vote
1 reply
@aislanspeedio
Comment options

Comment options

You must be logged in to vote
9 replies
@Froncast
Comment options

@Froncast
Comment options

@Ericles-Miller
Comment options

@Froncast
Comment options

@mkelley33
Comment options

Comment options

You must be logged in to vote
8 replies
@Froncast
Comment options

@lodeli-lulu
Comment options

@yashvesikar
Comment options

@lodeli-lulu
Comment options

@ailinalbertoni
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet