Auth: document an import for the generated Better Auth tables (`userTable`, …)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 62/100
- Issue 類型
- 文件
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- sqlite, typescript
- 領域
- backend, database, documentation
研究方向
在認證指南中記錄 .void/better-auth-schema.ts 及其匯出(userTable、sessionTable、accountTable、verificationTable),並包含一個指向 userTable.id 的外鍵範例。從現有的認證文件開始,那裡描述了來自 void/auth 的 AuthUser 和 AuthSession 型別,然後為這些資料表新增一個章節。指南展示匯入路徑、列出穩定的匯出並包含該範例即完成。公開匯入的提案留給維護者決定。
由索引模型根據 Issue 內容生成。
描述
Summary
Void generates the Better Auth tables into .void/better-auth-schema.ts (userTable, sessionTable, accountTable, verificationTable), but the docs never say how to import them. The auth guide documents the AuthUser and AuthSession types from void/auth, but not the tables.
An app that queries its users, or has a table that belongs to a user, needs those tables. Today the only way to get them is to point at the generated file yourself, and a release that renames the file or its exports breaks that app without warning.
Example
An admin page that lists users:
// tsconfig.json: our own alias, next to the `@schema` one Void configures
"paths": {
"@auth-schema": ["./.void/better-auth-schema.ts"]
}
// src/server/data/users.ts
import { userTable } from '@auth-schema';
import { db, desc } from 'void/db';
export function listUsers() {
return db.select().from(userTable).orderBy(desc(userTable.createdAt));
}
A table whose rows belong to a user needs the same import for its foreign key:
// db/schema.ts
import { userTable } from '@auth-schema';
import { sqliteTable, text } from 'void/schema-d1';
export const postTable = sqliteTable('post', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id, { onDelete: 'cascade' }),
});
Why it matters
- Users are app data too. Admin lists, "posts by this user" joins and foreign keys from app tables all need the table, not just the
AuthUsertype. - The generated file looks internal. It sits in
.void/with "Auto-generated by void — do not edit" at the top, so nothing tells an app it's safe to import. Its path and export names aren't documented, so an app can't tell what a release may change. - The tables already include the app's own columns. The generated
userTablehas the columns from Better Auth plugins anduser.additionalFields(such asroleandbannedfromadmin()), so it's the right table to query. Copying it by hand would drift.
Proposal
In order of preference:
- A public import, for example
import { userTable } from 'void/auth/schema', typed for the app's dialect and plugins. - An auto-configured alias, like the existing
@schemafordb/schema.ts. - At minimum, document
.void/better-auth-schema.tsand its export names as stable, with an example of a foreign key touserTable.idin the database or auth guide.
Environment
void1.5.0- D1 with Better Auth's
admin()plugin
- 主要語言
- TypeScript
- 星號
- 627
- 分支
- 66
- 平均合併
- 14 小時 56 分鐘
- 30 天內合併 PR
- 170
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/void 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 52/100
voidzero-dev/void#680 ·
維護者通常 1 天內回覆
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for files未關閉
難度 4/5 3-5 天 新手友好度 35/100
voidzero-dev/void#679 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 25/100
voidzero-dev/void#676 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 18/100
voidzero-dev/void#667 ·
維護者通常 1 天內回覆
-
platform: interrupted install ignores a replacement runtime token and never updates deployed Workers未關閉
難度 4/5 3-5 天 新手友好度 35/100
voidzero-dev/void#666 ·
維護者通常 1 天內回覆
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
oxidecomputer/skepsis#102 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
kunchenguid/gh-axi#247 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
lidge-jun/opencodex#8101 · 2 則留言 ·
維護者通常 1 天內回覆
-
effort:S P3 refactor
難度 2/5 1-3 小時 新手友好度 72/100
nightscout/nocturne#3243 ·
維護者通常 1 天內回覆