diff --git a/public/images/dbos.png b/public/images/dbos.png new file mode 100644 index 00000000..57a3e6f2 Binary files /dev/null and b/public/images/dbos.png differ diff --git a/src/components/LandingPage/Benchmark/Benchmark.tsx b/src/components/LandingPage/Benchmark/Benchmark.tsx index 9dbac470..21219810 100644 --- a/src/components/LandingPage/Benchmark/Benchmark.tsx +++ b/src/components/LandingPage/Benchmark/Benchmark.tsx @@ -35,12 +35,7 @@ const Benchmark = () => {
Performance
- Drizzle has always been fast, we just wanted you to have proper - benchmarks experience -
-
- Well, actually it's not that Drizzle is fast, Drizzle just - doesn't slow you down + Drizzle doesn't slow you down
diff --git a/src/components/layout/Banner.astro b/src/components/layout/Banner.astro index d5d83aa7..794ae1bc 100644 --- a/src/components/layout/Banner.astro +++ b/src/components/layout/Banner.astro @@ -1,6 +1,6 @@ diff --git a/src/content/documentation/docs/batch-api.mdx b/src/content/documentation/docs/batch-api.mdx index baf017d8..72ed183c 100644 --- a/src/content/documentation/docs/batch-api.mdx +++ b/src/content/documentation/docs/batch-api.mdx @@ -4,7 +4,7 @@ import Tabs from '@components/markdown/Tabs.astro'; # Batch API **LibSQL Batch API 解释**: -_[来源](https://docs.turso.tech/reference/client-access#batches)_ +_[来源](https://docs.turso.tech/sdk/ts/reference#batch-transactions)_ > 使用 libSQL 客户端库,批量是按顺序执行的一个或多个 SQL 语句,位于隐式事务中。 事务由 libSQL 后端控制。如果所有语句都成功,事务将提交。如果任何语句失败,整个事务将回滚,不会进行任何更改。 diff --git a/src/content/documentation/docs/column-types/pg.mdx b/src/content/documentation/docs/column-types/pg.mdx index 4cca7764..29261cc5 100644 --- a/src/content/documentation/docs/column-types/pg.mdx +++ b/src/content/documentation/docs/column-types/pg.mdx @@ -267,7 +267,7 @@ import { varchar, pgTable } from "drizzle-orm/pg-core"; export const table = pgTable('table', { varchar1: varchar('varchar1'), - varchar1: varchar('varchar2', { length: 256 }), + varchar2: varchar('varchar2', { length: 256 }), }); // 将被推断为 text: "value1" | "value2" | null @@ -820,8 +820,8 @@ import { integer, timestamp, text, pgTable } from "drizzle-orm/pg-core"; const table = pgTable('table', { updateCounter: integer('update_counter').default(sql`1`).$onUpdateFn((): SQL => sql`${table.update_counter} + 1`), - updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(() => new Date()), - alwaysNull: text('always_null').$type().$onUpdate(() => null), + updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(() => new Date()), + alwaysNull: text('always_null').$type().$onUpdate(() => null), }); ``` @@ -850,7 +850,7 @@ CREATE TABLE IF NOT EXISTS "table" ( 这要求值既唯一又不为 null。
```typescript -import { integer, pgTable } from "drizzle-orm/pg-core"; +import { serial, pgTable } from "drizzle-orm/pg-core"; const table = pgTable('table', { id: serial('id').primaryKey(), @@ -859,7 +859,7 @@ const table = pgTable('table', { ```sql CREATE TABLE IF NOT EXISTS "table" ( - "integer" serial PRIMARY KEY NOT NULL, + "id" serial PRIMARY KEY NOT NULL, ); ```
diff --git a/src/content/documentation/docs/get-started-postgresql.mdx b/src/content/documentation/docs/get-started-postgresql.mdx index 3666e956..6834b549 100644 --- a/src/content/documentation/docs/get-started-postgresql.mdx +++ b/src/content/documentation/docs/get-started-postgresql.mdx @@ -55,6 +55,17 @@ const db = drizzle(pool) const result = await db.select().from(...); ``` + + Additional configuration is required to use WebSockets in environments where the `WebSocket` global is not defined, such as Node.js. + + Add the `ws` and `bufferutil` packages to your project's dependencies, and set the `webSocketConstructor` config prior to creating a `Client` or `Pool` instance. + + ```typescript + import { Pool, neonConfig } from '@neondatabase/serverless'; + import ws from 'ws'; + neonConfig.webSocketConstructor = ws; + ``` + diff --git a/src/content/documentation/docs/get-started-sqlite.mdx b/src/content/documentation/docs/get-started-sqlite.mdx index a319377f..00d39bcf 100644 --- a/src/content/documentation/docs/get-started-sqlite.mdx +++ b/src/content/documentation/docs/get-started-sqlite.mdx @@ -69,11 +69,12 @@ node_compat = true binding = "DB" database_name = "YOUR DB NAME" database_id = "YOUR DB ID" +migrations_dir = "drizzle/migrations" ``` 初始化本地数据库并在本地运行服务器: ```bash -wrangler d1 execute --local --file=./drizzle/0000_short_lockheed.sql +wrangler d1 migrations apply --local wrangler dev ## 在版本低于 3.0.0 的 wrangler 加上 --local 和 --persist 标志 ``` @@ -550,4 +551,4 @@ const users = sqliteTable('users', { intModifiers: integer('int_modifiers', { mode: 'boolean' }).notNull().default(false), }); ``` -有关列类型的更多详细信息,请参阅 [Drizzle 中的 SQLite 列类型](/docs/column-types/sqlite)。 \ No newline at end of file +有关列类型的更多详细信息,请参阅 [Drizzle 中的 SQLite 列类型](/docs/column-types/sqlite)。 diff --git a/src/content/documentation/docs/graphql.mdx b/src/content/documentation/docs/graphql.mdx index f4204299..9dd6545e 100644 --- a/src/content/documentation/docs/graphql.mdx +++ b/src/content/documentation/docs/graphql.mdx @@ -23,12 +23,13 @@ import Npm from '@components/markdown/Npm.astro'; ```ts copy {1, 10} import { buildSchema } from 'drizzle-graphql'; import { drizzle } from 'drizzle-orm/...'; +import client from './db'; import { ApolloServer } from '@apollo/server'; import { startStandaloneServer } from '@apollo/server/standalone'; import * as dbSchema from './schema'; -const db = drizzle({ schema: dbSchema }); +const db = drizzle(client, { schema: dbSchema }); const { schema } = buildSchema(db); diff --git a/src/content/documentation/docs/indexes-constraints.mdx b/src/content/documentation/docs/indexes-constraints.mdx index 7b23b0bf..7d35a96e 100644 --- a/src/content/documentation/docs/indexes-constraints.mdx +++ b/src/content/documentation/docs/indexes-constraints.mdx @@ -755,11 +755,11 @@ Drizzle ORM 提供了几种声明外键的方法。 userLastName: text("user_last_name"), }, (table) => { return { - userReference: foreignKey(() => ({ + userReference: foreignKey({ columns: [table.userFirstName, table.userLastName], foreignColumns: [user.firstName, user.lastName], name: "custom_name" - })) + }) } }); ``` diff --git a/src/content/documentation/docs/joins.mdx b/src/content/documentation/docs/joins.mdx index b686288b..e3e73464 100644 --- a/src/content/documentation/docs/joins.mdx +++ b/src/content/documentation/docs/joins.mdx @@ -201,14 +201,14 @@ Drizzle ORM 支持表别名,这在您需要进行自连接时非常有用。 ```typescript copy import { user } from "./schema"; -const parent = alias(user, "parent") +const parent = aliasedTable(user, "parent") const result = db .select() .from(user) - .leftJoin(parent, eq(parent.id, user.id)); + .leftJoin(parent, eq(parent.id, user.parentId)); ``` ```sql -select ... from "user" left join "user" "parent" on "parent"."id" = "user"."id" +select ... from "user" left join "user" "parent" on "parent"."id" = "user"."parent_id" ``` ```typescript // result type @@ -242,8 +242,8 @@ Drizzle ORM 从驱动程序中提供名称映射的结果,而不改变结构 您可以自由地以您想要的方式操作结果,这里是一个映射一对多关系数据的示例: ```typescript -type User = typeof usersTable.$inferSelect; -type Pet = typeof usersTable.$inferSelect; +type User = typeof users.$inferSelect; +type Pet = typeof pets.$inferSelect; const rows = db.select({ user: users, diff --git a/src/content/documentation/docs/operators.mdx b/src/content/documentation/docs/operators.mdx index f55263f6..13058ca8 100644 --- a/src/content/documentation/docs/operators.mdx +++ b/src/content/documentation/docs/operators.mdx @@ -299,7 +299,7 @@ SELECT * FROM table WHERE EXISTS (SELECT * from table2)
```typescript -import { exists } from "drizzle-orm"; +import { notExists } from "drizzle-orm"; const query = db.select().from(table2) db.select().from(table).where(notExists(query)); @@ -500,4 +500,4 @@ const overlaps = await db.select({ id: posts.id }).from(posts) ```sql select "id" from "posts" where "posts"."tags" && {Typescript,ORM} ``` -
\ No newline at end of file + diff --git a/src/content/documentation/docs/perf-queries.mdx b/src/content/documentation/docs/perf-queries.mdx index cb68f318..94d6d1dd 100644 --- a/src/content/documentation/docs/perf-queries.mdx +++ b/src/content/documentation/docs/perf-queries.mdx @@ -4,7 +4,7 @@ import Tabs from '@components/markdown/Tabs.astro'; # 查询性能 当涉及 **Drizzle** 时 — 我们是一个薄的 TypeScript 层,位于 SQL 之上,几乎没有额外开销,并且为了使其实际为 0,您可以利用我们的预处理语句 API。 -**当您向数据库运行查询时,会发生几件事情:** +**当您在数据库上运行查询时,会发生几件事情:** - 查询构建器的所有配置都被连接到 SQL 字符串中 - 该字符串和参数被发送到数据库驱动程序 - 驱动程序将 SQL 查询编译为二进制 SQL 可执行格式,并将其发送到数据库 diff --git a/src/content/documentation/docs/rqb.mdx b/src/content/documentation/docs/rqb.mdx index abd1c26b..ac4e7013 100644 --- a/src/content/documentation/docs/rqb.mdx +++ b/src/content/documentation/docs/rqb.mdx @@ -165,6 +165,10 @@ export const profileInfo = pgTable('profile_info', { metadata: jsonb('metadata'), }); +export const profileInfoRelations = relations(profileInfo, ({ one }) => ({ + user: one(users, { fields: [profileInfo.userId], references: [users.id] }), +})); + const user = await queryUserWithProfileInfo(); //____^? type { id: number, profileInfo: { ... } | null } ``` diff --git a/src/content/documentation/docs/set-operations.mdx b/src/content/documentation/docs/set-operations.mdx index a2fb87a2..8c6836a7 100644 --- a/src/content/documentation/docs/set-operations.mdx +++ b/src/content/documentation/docs/set-operations.mdx @@ -974,4 +974,4 @@ SQL 集合操作将多个查询块的结果合并为一个结果。 SQL 标准 - \ No newline at end of file + diff --git a/src/content/documentation/docs/transactions.mdx b/src/content/documentation/docs/transactions.mdx index ea782fca..0dc25d0f 100644 --- a/src/content/documentation/docs/transactions.mdx +++ b/src/content/documentation/docs/transactions.mdx @@ -34,14 +34,14 @@ await db.transaction(async (tx) => { 您可以将业务逻辑嵌入事务中,并在需要时回滚: -```ts copy {6} +```ts copy {7} const db = drizzle(...) await db.transaction(async (tx) => { const [account] = await tx.select({ balance: accounts.balance }).from(accounts).where(eq(users.name, 'Dan')); if (account.balance < 100) { - await tx.rollback() - return + // This throws an exception that rollbacks the transaction. + tx.rollback() } await tx.update(accounts).set({ balance: sql`${accounts.balance} - 100.00` }).where(eq(users.name, 'Dan')); diff --git a/src/content/documentation/docs/update.mdx b/src/content/documentation/docs/update.mdx index 02e65424..930f1c03 100644 --- a/src/content/documentation/docs/update.mdx +++ b/src/content/documentation/docs/update.mdx @@ -10,6 +10,16 @@ await db.update(users) .where(eq(users.name, 'Dan')); ``` +您传递给 `update` 的对象应该具有与数据库架构中列名匹配的键。 +对象中忽略 `undefined` 的值:要将列设置为 `null`,请传递 `null`。 +您可以将 SQL 作为值传递给更新对象,就像这样: + +```typescript copy +await db.update(users) + .set({ updatedAt: sql`NOW()` }) + .where(eq(users.name, 'Dan')); +``` + ### 带返回值的更新 您可以在 PostgreSQL 和 SQLite 中更新一行并获取它回来: @@ -49,4 +59,4 @@ update "products" set "cheap" = $1 where "products"."price" < (select * from "average_price") returning "id" ``` - \ No newline at end of file + diff --git a/src/content/documentation/kit-docs/config-reference.mdx b/src/content/documentation/kit-docs/config-reference.mdx index 922dcceb..1f9fc194 100644 --- a/src/content/documentation/kit-docs/config-reference.mdx +++ b/src/content/documentation/kit-docs/config-reference.mdx @@ -216,7 +216,7 @@ import { defineConfig } from 'drizzle-kit' export default defineConfig({ dbCredentials: { - url: '', // 👈 this could also be a path to the local sqlite file + url: '', // 👈 this could also be a path to the local sqlite file using 'file:<>' } }) ``` diff --git a/src/content/documentation/kit-docs/upgrade-21.mdx b/src/content/documentation/kit-docs/upgrade-21.mdx index 637d835d..b59c828f 100644 --- a/src/content/documentation/kit-docs/upgrade-21.mdx +++ b/src/content/documentation/kit-docs/upgrade-21.mdx @@ -15,7 +15,7 @@ import { defineConfig } from "drizzle-kit" export default defineConfig({ dialect: "sqlite", // "postgresql" | "mysql" - driver: "turso" // 仅在使用 `aws-data-api`、`turso`、`d1-http`(WIP) 或 `expo` 时使用 + driver: "turso", // 仅在使用 `aws-data-api`、`turso`、`d1-http`(WIP) 或 `expo` 时使用 dbCredentials: { url: "" } diff --git a/src/content/guides/limit-offset-pagination.mdx b/src/content/guides/limit-offset-pagination.mdx index 19aab699..8befac3c 100644 --- a/src/content/guides/limit-offset-pagination.mdx +++ b/src/content/guides/limit-offset-pagination.mdx @@ -179,7 +179,7 @@ await withPagination(query.$dynamic(), asc(users.id)); 要实现它,可以这样做: ```ts copy {10} -const getUsets = async (page = 1, pageSize = 10) => { +const getUsers = async (page = 1, pageSize = 10) => { const sq = db .select({ id: users.id }) .from(users) diff --git a/src/data/s.ts b/src/data/s.ts index 95dbe4bb..f81302ff 100644 --- a/src/data/s.ts +++ b/src/data/s.ts @@ -270,6 +270,21 @@ export const sponsorsData: ISponsor[] = [ isActive: true, imageType: ImageType.IMAGE, }, + { + tier: { + name: "$250 a month", + isOneTime: false, + }, + sponsorEntity: { + __typename: "Organization", + login: "driz.link/dbos", + name: "DBOS", + avatarUrl: "/images/dbos.png", + }, + createdAt: "2024-08-13T16:35:56Z", + isActive: true, + imageType: ImageType.IMAGE, + }, ]; export default sponsorsData; diff --git a/src/data/shipping.yaml b/src/data/shipping.yaml index b8e7eba9..ba3cb791 100644 --- a/src/data/shipping.yaml +++ b/src/data/shipping.yaml @@ -1,3 +1,6 @@ +2024-08-19: + - We've updated benchmarks 🚀 + 2024-08-05: - | Drizzle Gateway closed alpha release 🎉