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 小时 38 分钟
- 30 天内合并 PR
- 179
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 5/5 一周以上 新手友好度 30/100
voidzero-dev/void#689 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
voidzero-dev/void#686 ·
维护者通常 1 天内回复
-
难度 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 天内回复
-
`Link`: mark the link to the current page (`aria-current`, `data-active`)可能已有人在做 @yangshun 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
voidzero-dev/void#676 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
pingdotgg/t3code#30228 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
难度 2/5 1-3 小时 新手友好度 66/100
vfarcic/dot-agent-deck#2079 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 1 天内回复