Jul 20, 2022
DrizzleORM - 是一个开源的 TypeScript ORM,支持 PostgreSQL,并计划在几周内提供 MySQL 和 SQLite 的支持。我们决定是时候与公众分享了。
通过 drizzle,您可以在代码中拥有完全类型化的 SQL 模式,这将以多种不同的主要方式使您受益。稍后我将详细介绍。
这是一个快速入门示例,介绍了如何连接到数据库并进行第一次查询并获得类型化的结果。
以下是如何使用 WHERE
条件语句和过滤器,在查询中使用部分选择,使用 limit/offset
和 orderBy
以下是如何运行 插入
、更新
和 删除
操作
我们 ORM 中最强大的功能之一是完全类型化的连接操作,编译器将不会让您犯任何错误。
下面是 多对多
关系的示例
最后,我们来谈谈迁移。我们为自动生成迁移的 CLI 工具进行了实现,该工具可以处理重命名和删除操作,并提示您进行解决。
对于下方的 TypeScript 模式