I was just wondering if it is somehow possible to provide multiple TypeScript classes as a package so that they can be used by multiple classes.
For example, I use the same class in three of my projects, and as soon as I change something in one project there, I inevitably have to copy the file to the other projects, and apply the changes from there as well, if they exist, which is more or less tedious.
Now I thought that I could create a private package, which contains these classes to consume them in the respective projects.
But now I have the question, is this possible with Prisma? Let's assume I have a database management class, and a model from my Prisma schema is expected as a parameter, theoretically I would have to include my Prisma schema in the package, or am I seeing this wrong?
Unfortunately I didn't find any solutions on various other sites, so I have this question.
CodePudding user response:
- using
private CDN
ornpm
package is a good choice for this kind of use case. follow this link
2. You can definitely gather all your classes
inside a single file and import it whenever you need it.
3. For prisma , schema.prisma
, I guess you might need to write some code's in Node js
in order to reade your schema.prisma
file from your package and merge it with your local schema.prisma
, because datasource
is specific for each project. After that you can create a newly create schema.prisma
file to pull
, push
or etc to your database
datasource db {
provider = "postgresql"
url = "postgres://......"
}