PrismaJS 从数据库(如 Hibernate)逆向工程?
PrismaJS Reverse Engineered from DB (like Hibernate)?
我有很多使用 Hibernate 从数据库实例逆向工程实体 类 (Java) 的经验,(这个过程是 'reverse' 基于写入实体 类)。通常,对于现有数据和流程,必须将数据库视为单个 'source of truth' 并基于数据库创建实体。
我对使用 Prisma (TS/JS) 很感兴趣,并且我一直在寻找可以基于现有的生成 Prisma 模式(用于生成实体 类)的生成器DB(逆向工程)。
有没有办法从现有数据库对 Prisma 模式进行逆向工程?是否有任何已知的项目可以添加此功能?
我相信您正在寻找 Prisma 的内省功能。根据 Prisma 文档中的 Introspection Concept Article:
You can introspect your database using the Prisma CLI in order to generate the data model in your Prisma schema.
....
Introspection is often used to generate an initial version of the data model when adding Prisma to an existing project.
设置数据库连接后用于自省的prisma cli
命令:
npx prisma introspect
这应该使用现有的数据库表更新您的 Prisma 架构文件。
我有很多使用 Hibernate 从数据库实例逆向工程实体 类 (Java) 的经验,(这个过程是 'reverse' 基于写入实体 类)。通常,对于现有数据和流程,必须将数据库视为单个 'source of truth' 并基于数据库创建实体。
我对使用 Prisma (TS/JS) 很感兴趣,并且我一直在寻找可以基于现有的生成 Prisma 模式(用于生成实体 类)的生成器DB(逆向工程)。
有没有办法从现有数据库对 Prisma 模式进行逆向工程?是否有任何已知的项目可以添加此功能?
我相信您正在寻找 Prisma 的内省功能。根据 Prisma 文档中的 Introspection Concept Article:
You can introspect your database using the Prisma CLI in order to generate the data model in your Prisma schema.
....
Introspection is often used to generate an initial version of the data model when adding Prisma to an existing project.
设置数据库连接后用于自省的prisma cli
命令:
npx prisma introspect
这应该使用现有的数据库表更新您的 Prisma 架构文件。