Hi there. I was wondering if someone might be able...
# orm-help
k
Hi there. I was wondering if someone might be able to help me in setting up Helper Methods with Prisma. Is there any way to replicate the following TypeORM class helper function in Prisma? https://gist.github.com/jtushman/673f5cd9c0225ee50951fcf46be24df5
a
My sense is that Prisma doesn't really use helper methods the same way as other ORMs.
The pattern is usually to create a function or set of functions that would do any of that processing before saving.
plus one +1 2
r
Yup that’s the way to go. Prisma isn’t a class based ORM so you would need to create individual helper functions that perform this operation.
k
What about if I want to do some sort of fetching? i.e.
Copy code
getFullName(){
    return `${this.firstName} ${this.lastName}`;
}
// call
user.getFullName()
I assume this would need to be an external helper function, too?
r
Yes, a function that will add this property by mapping over your results.