@auth/d1-adapter
Auth.js / NextAuth.js 的官方 Cloudflare D1 适配器。
警告
此适配器並非由 Cloudflare 開發或維護,且他們尚未聲明 D1 API 為穩定版本。作者會盡力保持此适配器為最新狀態。此适配器與截至 2023 年 3 月 22 日的 D1 API 相容。
安裝
npm install next-auth @auth/d1-adapter
D1Database
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
>>