DrizzleORM v0.28.3 发布
Aug 22, 2023
修复
- 修复了当结果为空时 sqlite-proxy 和 SQL.js 的
.get()
响应
新特性
🎉 添加了 SQLite 简化查询 API
🎉 为列构建器添加了 .$defaultFn()
/ .$default()
方法
有关更多信息,请查看 PostgreSQL、MySQL 和 SQLite 的文档。
您可以为运行时默认值指定任意逻辑和实现,例如 cuid()
。Drizzle 不会限制您可以添加的实现数量。
注意:该值不会影响
drizzle-kit
的行为,仅在drizzle-orm
的运行时使用。
import { varchar, mysqlTable } from "drizzle-orm/mysql-core";
import { createId } from '@paralleldrive/cuid2';
const table = mysqlTable('table', {
id: varchar('id', { length: 128 }).$defaultFn(() => createId()),
});
🎉 添加了 table.$inferSelect
/ table._.inferSelect
和 table.$inferInsert
/ table._.inferInsert
以便更方便的表模型类型推断
- 🛠 废弃
InferModel
类型,采用更明确的InferSelectModel
和InferInsertModel
import { InferSelectModel, InferInsertModel } from 'drizzle-orm'
const usersTable = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
verified: boolean('verified').notNull().default(false),
jsonb: jsonb('jsonb').$type<string[]>(),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});
type SelectUser = typeof usersTable.$inferSelect;
type InsertUser = typeof usersTable.$inferInsert;
type SelectUser2 = InferSelectModel<typeof usersTable>;
type InsertUser2 = InferInsertModel<typeof usersTable>;
- 🛠 禁用了
.d.ts
文件的打包