Possibility to merge & extend prisma models ?
See original GitHub issueAs there is most likely a parser for .prisma files (See #92) coming soon, it would be nice to have the possibility to merge & extend existing models, like:
post.prisma
model Post {
title String @pg.varchar(42)
body String
}
core.prisma
import "./post.prisma"
model User {
posts Post[]
}
Use case: let’s assume core.prisma
& post.prisma
are a package dependency and I’d like to extend and overwrite the Post
model:
schema.prisma
import "dependency/prisma/core.prisma"
extend model Post {
title String @pg.varchar(50)
slug String
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:44
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Custom models - Prisma
This page explains how to wrap Prisma Client in custom models. ... We suggest either wrapping a model in a class or extending...
Read more >Prisma Client extensions (Preview)
When you combine two or more extensions into a single extended client, then the last extension that you declare takes precedence in any...
Read more >Prisma Client API (Reference)
With $extends , you can create and use Prisma Client extensions to add functionality to Prisma Client in the following ways: model :...
Read more >Prisma Client extensions: model component (Preview)
You can use the model Prisma Client extensions component type to add custom methods to your models. We introduced this feature in version...
Read more >Data model (Reference) - Prisma
Learn about the concepts for building your data model with Prisma: Models, scalar types, enums, attributes, functions, IDs, default values and more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Pasting your suggested API here:
The API suggested in the first post of this issue is not final or anything, it is just to showcase the idea but we appreciate your suggestion 😃
Yup, the interface type would be great
If multiple models are treated as a dependency, being able to extend & override its original value would be ideal, e.g:
Vendor applications:
That way, I can easily compose my prisma schema from existing datamodels.
I came across an interesting project that temporarily solves this issue: https://github.com/amplication/prisma-schema-dsl