@auth/d1-adapter
Auth.js / NextAuth.js 的官方 Cloudflare D1 适配器。
警告
此适配器并非由 Cloudflare 开发或维护,他们也没有声明 D1 api 稳定。作者将尽力使此适配器保持最新。此适配器与 2023 年 3 月 22 日的 D1 api 兼容。
安装
npm install next-auth @auth/d1-adapterD1Database
type D1Database: WorkerDatabase | MiniflareD1Database;D1Adapter()
D1Adapter(db): Adapter参数
| 参数 | 类型 |
|---|---|
db | D1Database |
返回值
createRecord()
createRecord<RecordType>(
db,
CREATE_SQL,
bindings,
GET_SQL,
getBindings): Promise<null | RecordType>类型参数
| 类型参数 |
|---|
RecordType |
参数
| 参数 | 类型 |
|---|---|
db | D1Database |
CREATE_SQL | string |
bindings | any[] |
GET_SQL | string |
getBindings | any[] |
返回值
Promise<null | RecordType>
deleteRecord()
deleteRecord(
db,
SQL,
bindings): Promise<void>参数
| 参数 | 类型 |
|---|---|
db | D1Database |
SQL | string |
bindings | any[] |
返回值
Promise<void>
getRecord()
getRecord<RecordType>(
db,
SQL,
bindings): Promise<RecordType | null>类型参数
| 类型参数 |
|---|
RecordType |
参数
| 参数 | 类型 |
|---|---|
db | D1Database |
SQL | string |
bindings | any[] |
返回值
Promise<RecordType | null>
up()
up(db): Promise<void>参数
| 参数 | 类型 |
|---|---|
db | D1Database |
返回值
Promise<void>
updateRecord()
updateRecord(
db,
SQL,
bindings): Promise<D1Result<unknown> | D1Result<unknown>>参数
| 参数 | 类型 |
|---|---|
db | D1Database |
SQL | string |
bindings | any[] |
返回值
Promise<D1Result<unknown> | D1Result<unknown>>