@auth/d1-adapter
An official Cloudflare D1 adapter for Auth.js / NextAuth.js.
Warning
This adapter is not developed or maintained by Cloudflare and they haven’t declared the D1 api stable. The author will make an effort to keep this adapter up to date. The adapter is compatible with the D1 api as of March 22, 2023.
Installation
npm install next-auth @auth/d1-adapter
D1Database
type D1Database: WorkerDatabase | MiniflareD1Database;
D1Adapter()
D1Adapter(db): Adapter
Parameters
Parameter | Type |
---|---|
db | D1Database |
Returns
createRecord()
createRecord<RecordType>(
db,
CREATE_SQL,
bindings,
GET_SQL,
getBindings): Promise<null | RecordType>
Type parameters
Type parameter |
---|
RecordType |
Parameters
Parameter | Type |
---|---|
db | D1Database |
CREATE_SQL | string |
bindings | any [] |
GET_SQL | string |
getBindings | any [] |
Returns
Promise
<null
| RecordType
>
deleteRecord()
deleteRecord(
db,
SQL,
bindings): Promise<void>
Parameters
Parameter | Type |
---|---|
db | D1Database |
SQL | string |
bindings | any [] |
Returns
Promise
<void
>
getRecord()
getRecord<RecordType>(
db,
SQL,
bindings): Promise<RecordType | null>
Type parameters
Type parameter |
---|
RecordType |
Parameters
Parameter | Type |
---|---|
db | D1Database |
SQL | string |
bindings | any [] |
Returns
Promise
<RecordType
| null
>
up()
up(db): Promise<void>
Parameters
Parameter | Type |
---|---|
db | D1Database |
Returns
Promise
<void
>
updateRecord()
updateRecord(
db,
SQL,
bindings): Promise<D1Result<unknown> | D1Result<unknown>>
Parameters
Parameter | Type |
---|---|
db | D1Database |
SQL | string |
bindings | any [] |
Returns
Promise
<D1Result
<unknown
> | D1Result
<unknown
>>