@auth/drizzle-adapter 0.0.0-manual.ffc00566 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <img height="64px" src="https://authjs.dev/img/logo/logo-sm.png" />
5
5
  </a>
6
6
  <a href="https://github.com/drizzle-team/drizzle-orm" target="_blank">
7
- <img height="64px" src="https://pbs.twimg.com/profile_images/1598308842391179266/CtXrfLnk_400x400.jpg"/>
7
+ <img height="64px" src="https://authjs.dev/img/adapters/drizzle-orm.png"/>
8
8
  </a>
9
9
  <h3 align="center"><b>Drizzle ORM Adapter</b> - NextAuth.js / Auth.js</a></h3>
10
10
  <p align="center" style="align: center;">
package/index.d.ts CHANGED
@@ -15,10 +15,10 @@
15
15
  *
16
16
  * @module @auth/drizzle-adapter
17
17
  */
18
- import { SqlFlavorOptions } from "./lib/utils";
18
+ import { SqlFlavorOptions, TableFn } from "./lib/utils.js";
19
19
  import type { Adapter } from "@auth/core/adapters";
20
20
  /**
21
- * Add the adapter to your `app/api/[...nextauth]/route.js` next-auth configuration object.
21
+ * Add the adapter to your `pages/api/[...nextauth].ts` next-auth configuration object.
22
22
  *
23
23
  * ```ts title="pages/api/auth/[...nextauth].ts"
24
24
  * import NextAuth from "next-auth"
@@ -37,6 +37,10 @@ import type { Adapter } from "@auth/core/adapters";
37
37
  * })
38
38
  * ```
39
39
  *
40
+ * :::info
41
+ * If you're using multi-project schemas, you can pass your table function as a second argument
42
+ * :::
43
+ *
40
44
  * ## Setup
41
45
  *
42
46
  * First, create a schema that includes [the minimum requirements for a `next-auth` adapter](/reference/adapters#models). You can select your favorite SQL flavor below and copy it.
@@ -237,5 +241,5 @@ import type { Adapter } from "@auth/core/adapters";
237
241
  * ---
238
242
  *
239
243
  **/
240
- export declare function DrizzleAdapter<SqlFlavor extends SqlFlavorOptions>(db: SqlFlavor): Adapter;
244
+ export declare function DrizzleAdapter<SqlFlavor extends SqlFlavorOptions>(db: SqlFlavor, table?: TableFn<SqlFlavor>): Adapter;
241
245
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAIL,gBAAgB,EACjB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2NI;AACJ,wBAAgB,cAAc,CAAC,SAAS,SAAS,gBAAgB,EAC/D,EAAE,EAAE,SAAS,GACZ,OAAO,CAeT"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,EAIL,gBAAgB,EAChB,OAAO,EACR,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+NI;AACJ,wBAAgB,cAAc,CAAC,SAAS,SAAS,gBAAgB,EAC/D,EAAE,EAAE,SAAS,EACb,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GACzB,OAAO,CAeT"}
package/index.js CHANGED
@@ -15,12 +15,12 @@
15
15
  *
16
16
  * @module @auth/drizzle-adapter
17
17
  */
18
- import { mySqlDrizzleAdapter } from "./lib/mysql";
19
- import { pgDrizzleAdapter } from "./lib/pg";
20
- import { SQLiteDrizzleAdapter } from "./lib/sqlite";
21
- import { isMySqlDatabase, isPgDatabase, isSQLiteDatabase, } from "./lib/utils";
18
+ import { mySqlDrizzleAdapter } from "./lib/mysql.js";
19
+ import { pgDrizzleAdapter } from "./lib/pg.js";
20
+ import { SQLiteDrizzleAdapter } from "./lib/sqlite.js";
21
+ import { isMySqlDatabase, isPgDatabase, isSQLiteDatabase, } from "./lib/utils.js";
22
22
  /**
23
- * Add the adapter to your `app/api/[...nextauth]/route.js` next-auth configuration object.
23
+ * Add the adapter to your `pages/api/[...nextauth].ts` next-auth configuration object.
24
24
  *
25
25
  * ```ts title="pages/api/auth/[...nextauth].ts"
26
26
  * import NextAuth from "next-auth"
@@ -39,6 +39,10 @@ import { isMySqlDatabase, isPgDatabase, isSQLiteDatabase, } from "./lib/utils";
39
39
  * })
40
40
  * ```
41
41
  *
42
+ * :::info
43
+ * If you're using multi-project schemas, you can pass your table function as a second argument
44
+ * :::
45
+ *
42
46
  * ## Setup
43
47
  *
44
48
  * First, create a schema that includes [the minimum requirements for a `next-auth` adapter](/reference/adapters#models). You can select your favorite SQL flavor below and copy it.
@@ -239,16 +243,16 @@ import { isMySqlDatabase, isPgDatabase, isSQLiteDatabase, } from "./lib/utils";
239
243
  * ---
240
244
  *
241
245
  **/
242
- export function DrizzleAdapter(db) {
246
+ export function DrizzleAdapter(db, table) {
243
247
  if (isMySqlDatabase(db)) {
244
248
  // We need to cast to unknown since the type overlaps (PScale is MySQL based)
245
- return mySqlDrizzleAdapter(db);
249
+ return mySqlDrizzleAdapter(db, table);
246
250
  }
247
251
  if (isPgDatabase(db)) {
248
- return pgDrizzleAdapter(db);
252
+ return pgDrizzleAdapter(db, table);
249
253
  }
250
254
  if (isSQLiteDatabase(db)) {
251
- return SQLiteDrizzleAdapter(db);
255
+ return SQLiteDrizzleAdapter(db, table);
252
256
  }
253
257
  throw new Error("Unsupported database type in Auth.js Drizzle adapter.");
254
258
  }
package/lib/mysql.d.ts CHANGED
@@ -1,2 +1,226 @@
1
- export type DefaultSchema = typeof schema;
1
+ import { MySqlTableFn } from "drizzle-orm/mysql-core";
2
+ import type { Adapter } from "@auth/core/adapters";
3
+ import type { MySql2Database } from "drizzle-orm/mysql2";
4
+ export declare function createTables(mySqlTable: MySqlTableFn): {
5
+ users: import("drizzle-orm/select.types.d-b947a018").aw<{
6
+ name: "users";
7
+ schema: undefined;
8
+ columns: {
9
+ id: import("drizzle-orm/mysql-core").MySqlVarChar<{
10
+ tableName: "users";
11
+ enumValues: [string, ...string[]];
12
+ name: "id";
13
+ data: string;
14
+ driverParam: string | number;
15
+ hasDefault: false;
16
+ notNull: true;
17
+ }>;
18
+ name: import("drizzle-orm/mysql-core").MySqlVarChar<{
19
+ tableName: "users";
20
+ name: "name";
21
+ data: string;
22
+ driverParam: string | number;
23
+ enumValues: [string, ...string[]];
24
+ notNull: false;
25
+ hasDefault: false;
26
+ }>;
27
+ email: import("drizzle-orm/mysql-core").MySqlVarChar<{
28
+ tableName: "users";
29
+ enumValues: [string, ...string[]];
30
+ name: "email";
31
+ data: string;
32
+ driverParam: string | number;
33
+ hasDefault: false;
34
+ notNull: true;
35
+ }>;
36
+ emailVerified: import("drizzle-orm/mysql-core").MySqlTimestamp<{
37
+ tableName: "users";
38
+ name: "emailVerified";
39
+ data: Date;
40
+ driverParam: string | number;
41
+ notNull: false;
42
+ hasDefault: true;
43
+ }>;
44
+ image: import("drizzle-orm/mysql-core").MySqlVarChar<{
45
+ tableName: "users";
46
+ name: "image";
47
+ data: string;
48
+ driverParam: string | number;
49
+ enumValues: [string, ...string[]];
50
+ notNull: false;
51
+ hasDefault: false;
52
+ }>;
53
+ };
54
+ }>;
55
+ accounts: import("drizzle-orm/select.types.d-b947a018").aw<{
56
+ name: "accounts";
57
+ schema: undefined;
58
+ columns: {
59
+ userId: import("drizzle-orm/mysql-core").MySqlVarChar<{
60
+ tableName: "accounts";
61
+ enumValues: [string, ...string[]];
62
+ name: "userId";
63
+ data: string;
64
+ driverParam: string | number;
65
+ hasDefault: false;
66
+ notNull: true;
67
+ }>;
68
+ type: import("drizzle-orm/mysql-core").MySqlVarChar<{
69
+ tableName: "accounts";
70
+ enumValues: [string, ...string[]];
71
+ name: "type";
72
+ data: "email" | "oidc" | "oauth";
73
+ driverParam: string | number;
74
+ hasDefault: false;
75
+ notNull: true;
76
+ }>;
77
+ provider: import("drizzle-orm/mysql-core").MySqlVarChar<{
78
+ tableName: "accounts";
79
+ enumValues: [string, ...string[]];
80
+ name: "provider";
81
+ data: string;
82
+ driverParam: string | number;
83
+ hasDefault: false;
84
+ notNull: true;
85
+ }>;
86
+ providerAccountId: import("drizzle-orm/mysql-core").MySqlVarChar<{
87
+ tableName: "accounts";
88
+ enumValues: [string, ...string[]];
89
+ name: "providerAccountId";
90
+ data: string;
91
+ driverParam: string | number;
92
+ hasDefault: false;
93
+ notNull: true;
94
+ }>;
95
+ refresh_token: import("drizzle-orm/mysql-core").MySqlVarChar<{
96
+ tableName: "accounts";
97
+ name: "refresh_token";
98
+ data: string;
99
+ driverParam: string | number;
100
+ enumValues: [string, ...string[]];
101
+ notNull: false;
102
+ hasDefault: false;
103
+ }>;
104
+ access_token: import("drizzle-orm/mysql-core").MySqlVarChar<{
105
+ tableName: "accounts";
106
+ name: "access_token";
107
+ data: string;
108
+ driverParam: string | number;
109
+ enumValues: [string, ...string[]];
110
+ notNull: false;
111
+ hasDefault: false;
112
+ }>;
113
+ expires_at: import("drizzle-orm/mysql-core").MySqlInt<{
114
+ tableName: "accounts";
115
+ name: "expires_at";
116
+ data: number;
117
+ driverParam: string | number;
118
+ notNull: false;
119
+ hasDefault: false;
120
+ }>;
121
+ token_type: import("drizzle-orm/mysql-core").MySqlVarChar<{
122
+ tableName: "accounts";
123
+ name: "token_type";
124
+ data: string;
125
+ driverParam: string | number;
126
+ enumValues: [string, ...string[]];
127
+ notNull: false;
128
+ hasDefault: false;
129
+ }>;
130
+ scope: import("drizzle-orm/mysql-core").MySqlVarChar<{
131
+ tableName: "accounts";
132
+ name: "scope";
133
+ data: string;
134
+ driverParam: string | number;
135
+ enumValues: [string, ...string[]];
136
+ notNull: false;
137
+ hasDefault: false;
138
+ }>;
139
+ id_token: import("drizzle-orm/mysql-core").MySqlVarChar<{
140
+ tableName: "accounts";
141
+ name: "id_token";
142
+ data: string;
143
+ driverParam: string | number;
144
+ enumValues: [string, ...string[]];
145
+ notNull: false;
146
+ hasDefault: false;
147
+ }>;
148
+ session_state: import("drizzle-orm/mysql-core").MySqlVarChar<{
149
+ tableName: "accounts";
150
+ name: "session_state";
151
+ data: string;
152
+ driverParam: string | number;
153
+ enumValues: [string, ...string[]];
154
+ notNull: false;
155
+ hasDefault: false;
156
+ }>;
157
+ };
158
+ }>;
159
+ sessions: import("drizzle-orm/select.types.d-b947a018").aw<{
160
+ name: "sessions";
161
+ schema: undefined;
162
+ columns: {
163
+ sessionToken: import("drizzle-orm/mysql-core").MySqlVarChar<{
164
+ tableName: "sessions";
165
+ enumValues: [string, ...string[]];
166
+ name: "sessionToken";
167
+ data: string;
168
+ driverParam: string | number;
169
+ hasDefault: false;
170
+ notNull: true;
171
+ }>;
172
+ userId: import("drizzle-orm/mysql-core").MySqlVarChar<{
173
+ tableName: "sessions";
174
+ enumValues: [string, ...string[]];
175
+ name: "userId";
176
+ data: string;
177
+ driverParam: string | number;
178
+ hasDefault: false;
179
+ notNull: true;
180
+ }>;
181
+ expires: import("drizzle-orm/mysql-core").MySqlTimestamp<{
182
+ tableName: "sessions";
183
+ name: "expires";
184
+ data: Date;
185
+ driverParam: string | number;
186
+ hasDefault: false;
187
+ notNull: true;
188
+ }>;
189
+ };
190
+ }>;
191
+ verificationTokens: import("drizzle-orm/select.types.d-b947a018").aw<{
192
+ name: "verificationToken";
193
+ schema: undefined;
194
+ columns: {
195
+ identifier: import("drizzle-orm/mysql-core").MySqlVarChar<{
196
+ tableName: "verificationToken";
197
+ enumValues: [string, ...string[]];
198
+ name: "identifier";
199
+ data: string;
200
+ driverParam: string | number;
201
+ hasDefault: false;
202
+ notNull: true;
203
+ }>;
204
+ token: import("drizzle-orm/mysql-core").MySqlVarChar<{
205
+ tableName: "verificationToken";
206
+ enumValues: [string, ...string[]];
207
+ name: "token";
208
+ data: string;
209
+ driverParam: string | number;
210
+ hasDefault: false;
211
+ notNull: true;
212
+ }>;
213
+ expires: import("drizzle-orm/mysql-core").MySqlTimestamp<{
214
+ tableName: "verificationToken";
215
+ name: "expires";
216
+ data: Date;
217
+ driverParam: string | number;
218
+ hasDefault: false;
219
+ notNull: true;
220
+ }>;
221
+ };
222
+ }>;
223
+ };
224
+ export type DefaultSchema = ReturnType<typeof createTables>;
225
+ export declare function mySqlDrizzleAdapter(client: MySql2Database<Record<string, never>>, tableFn?: MySqlTableFn<undefined>): Adapter;
2
226
  //# sourceMappingURL=mysql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../src/lib/mysql.ts"],"names":[],"mappings":"AAwEA,MAAM,MAAM,aAAa,GAAG,OAAO,MAAM,CAAA"}
1
+ {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../src/lib/mysql.ts"],"names":[],"mappings":"AACA,OAAO,EAML,YAAY,EACb,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,wBAAgB,YAAY,CAAC,UAAU,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DpD;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAE3D,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAC7C,OAAO,0BAAsB,GAC5B,OAAO,CAyLT"}
package/lib/mysql.js CHANGED
@@ -1,58 +1,59 @@
1
1
  import { and, eq } from "drizzle-orm";
2
- import { int, timestamp, mysqlTable, primaryKey, varchar, } from "drizzle-orm/mysql-core";
3
- /** @internal */
4
- export const users = mysqlTable("users", {
5
- id: varchar("id", { length: 255 }).notNull().primaryKey(),
6
- name: varchar("name", { length: 255 }),
7
- email: varchar("email", { length: 255 }).notNull(),
8
- emailVerified: timestamp("emailVerified", {
9
- mode: "date",
10
- fsp: 3,
11
- }).defaultNow(),
12
- image: varchar("image", { length: 255 }),
13
- });
14
- /** @internal */
15
- export const accounts = mysqlTable("accounts", {
16
- userId: varchar("userId", { length: 255 })
17
- .notNull()
18
- .references(() => users.id, { onDelete: "cascade" }),
19
- type: varchar("type", { length: 255 })
20
- .$type()
21
- .notNull(),
22
- provider: varchar("provider", { length: 255 }).notNull(),
23
- providerAccountId: varchar("providerAccountId", { length: 255 }).notNull(),
24
- refresh_token: varchar("refresh_token", { length: 255 }),
25
- access_token: varchar("access_token", { length: 255 }),
26
- expires_at: int("expires_at"),
27
- token_type: varchar("token_type", { length: 255 }),
28
- scope: varchar("scope", { length: 255 }),
29
- id_token: varchar("id_token", { length: 255 }),
30
- session_state: varchar("session_state", { length: 255 }),
31
- }, (account) => ({
32
- compoundKey: primaryKey(account.provider, account.providerAccountId),
33
- }));
34
- /** @internal */
35
- export const sessions = mysqlTable("sessions", {
36
- sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(),
37
- userId: varchar("userId", { length: 255 })
38
- .notNull()
39
- .references(() => users.id, { onDelete: "cascade" }),
40
- expires: timestamp("expires", { mode: "date" }).notNull(),
41
- });
42
- /** @internal */
43
- export const verificationTokens = mysqlTable("verificationToken", {
44
- identifier: varchar("identifier", { length: 255 }).notNull(),
45
- token: varchar("token", { length: 255 }).notNull(),
46
- expires: timestamp("expires", { mode: "date" }).notNull(),
47
- }, (vt) => ({
48
- compoundKey: primaryKey(vt.identifier, vt.token),
49
- }));
50
- /** @internal */
51
- export const schema = { users, accounts, sessions, verificationTokens };
52
- /** @internal */
53
- export function mySqlDrizzleAdapter(client) {
2
+ import { int, timestamp, mysqlTable as defaultMySqlTableFn, primaryKey, varchar, } from "drizzle-orm/mysql-core";
3
+ export function createTables(mySqlTable) {
4
+ const users = mySqlTable("users", {
5
+ id: varchar("id", { length: 255 }).notNull().primaryKey(),
6
+ name: varchar("name", { length: 255 }),
7
+ email: varchar("email", { length: 255 }).notNull(),
8
+ emailVerified: timestamp("emailVerified", {
9
+ mode: "date",
10
+ fsp: 3,
11
+ }).defaultNow(),
12
+ image: varchar("image", { length: 255 }),
13
+ });
14
+ const accounts = mySqlTable("accounts", {
15
+ userId: varchar("userId", { length: 255 })
16
+ .notNull()
17
+ .references(() => users.id, { onDelete: "cascade" }),
18
+ type: varchar("type", { length: 255 })
19
+ .$type()
20
+ .notNull(),
21
+ provider: varchar("provider", { length: 255 }).notNull(),
22
+ providerAccountId: varchar("providerAccountId", {
23
+ length: 255,
24
+ }).notNull(),
25
+ refresh_token: varchar("refresh_token", { length: 255 }),
26
+ access_token: varchar("access_token", { length: 255 }),
27
+ expires_at: int("expires_at"),
28
+ token_type: varchar("token_type", { length: 255 }),
29
+ scope: varchar("scope", { length: 255 }),
30
+ id_token: varchar("id_token", { length: 255 }),
31
+ session_state: varchar("session_state", { length: 255 }),
32
+ }, (account) => ({
33
+ compoundKey: primaryKey(account.provider, account.providerAccountId),
34
+ }));
35
+ const sessions = mySqlTable("sessions", {
36
+ sessionToken: varchar("sessionToken", { length: 255 })
37
+ .notNull()
38
+ .primaryKey(),
39
+ userId: varchar("userId", { length: 255 })
40
+ .notNull()
41
+ .references(() => users.id, { onDelete: "cascade" }),
42
+ expires: timestamp("expires", { mode: "date" }).notNull(),
43
+ });
44
+ const verificationTokens = mySqlTable("verificationToken", {
45
+ identifier: varchar("identifier", { length: 255 }).notNull(),
46
+ token: varchar("token", { length: 255 }).notNull(),
47
+ expires: timestamp("expires", { mode: "date" }).notNull(),
48
+ }, (vt) => ({
49
+ compoundKey: primaryKey(vt.identifier, vt.token),
50
+ }));
51
+ return { users, accounts, sessions, verificationTokens };
52
+ }
53
+ export function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
54
+ const { users, accounts, sessions, verificationTokens } = createTables(tableFn);
54
55
  return {
55
- createUser: async (data) => {
56
+ async createUser(data) {
56
57
  const id = crypto.randomUUID();
57
58
  await client.insert(users).values({ ...data, id });
58
59
  return await client
@@ -61,7 +62,7 @@ export function mySqlDrizzleAdapter(client) {
61
62
  .where(eq(users.id, id))
62
63
  .then((res) => res[0]);
63
64
  },
64
- getUser: async (data) => {
65
+ async getUser(data) {
65
66
  const thing = (await client
66
67
  .select()
67
68
  .from(users)
@@ -69,7 +70,7 @@ export function mySqlDrizzleAdapter(client) {
69
70
  .then((res) => res[0])) ?? null;
70
71
  return thing;
71
72
  },
72
- getUserByEmail: async (data) => {
73
+ async getUserByEmail(data) {
73
74
  const user = (await client
74
75
  .select()
75
76
  .from(users)
@@ -77,7 +78,7 @@ export function mySqlDrizzleAdapter(client) {
77
78
  .then((res) => res[0])) ?? null;
78
79
  return user;
79
80
  },
80
- createSession: async (data) => {
81
+ async createSession(data) {
81
82
  await client.insert(sessions).values(data);
82
83
  return await client
83
84
  .select()
@@ -85,7 +86,7 @@ export function mySqlDrizzleAdapter(client) {
85
86
  .where(eq(sessions.sessionToken, data.sessionToken))
86
87
  .then((res) => res[0]);
87
88
  },
88
- getSessionAndUser: async (data) => {
89
+ async getSessionAndUser(data) {
89
90
  const sessionAndUser = (await client
90
91
  .select({
91
92
  session: sessions,
@@ -97,7 +98,7 @@ export function mySqlDrizzleAdapter(client) {
97
98
  .then((res) => res[0])) ?? null;
98
99
  return sessionAndUser;
99
100
  },
100
- updateUser: async (data) => {
101
+ async updateUser(data) {
101
102
  if (!data.id) {
102
103
  throw new Error("No user id.");
103
104
  }
@@ -108,7 +109,7 @@ export function mySqlDrizzleAdapter(client) {
108
109
  .where(eq(users.id, data.id))
109
110
  .then((res) => res[0]);
110
111
  },
111
- updateSession: async (data) => {
112
+ async updateSession(data) {
112
113
  await client
113
114
  .update(sessions)
114
115
  .set(data)
@@ -119,13 +120,13 @@ export function mySqlDrizzleAdapter(client) {
119
120
  .where(eq(sessions.sessionToken, data.sessionToken))
120
121
  .then((res) => res[0]);
121
122
  },
122
- linkAccount: async (rawAccount) => {
123
+ async linkAccount(rawAccount) {
123
124
  await client
124
125
  .insert(accounts)
125
126
  .values(rawAccount)
126
127
  .then((res) => res[0]);
127
128
  },
128
- getUserByAccount: async (account) => {
129
+ async getUserByAccount(account) {
129
130
  const dbAccount = (await client
130
131
  .select()
131
132
  .from(accounts)
@@ -137,7 +138,7 @@ export function mySqlDrizzleAdapter(client) {
137
138
  }
138
139
  return dbAccount.users;
139
140
  },
140
- deleteSession: async (sessionToken) => {
141
+ async deleteSession(sessionToken) {
141
142
  const session = (await client
142
143
  .select()
143
144
  .from(sessions)
@@ -148,7 +149,7 @@ export function mySqlDrizzleAdapter(client) {
148
149
  .where(eq(sessions.sessionToken, sessionToken));
149
150
  return session;
150
151
  },
151
- createVerificationToken: async (token) => {
152
+ async createVerificationToken(token) {
152
153
  await client.insert(verificationTokens).values(token);
153
154
  return await client
154
155
  .select()
@@ -156,7 +157,7 @@ export function mySqlDrizzleAdapter(client) {
156
157
  .where(eq(verificationTokens.identifier, token.identifier))
157
158
  .then((res) => res[0]);
158
159
  },
159
- useVerificationToken: async (token) => {
160
+ async useVerificationToken(token) {
160
161
  try {
161
162
  const deletedToken = (await client
162
163
  .select()
@@ -172,7 +173,7 @@ export function mySqlDrizzleAdapter(client) {
172
173
  throw new Error("No verification token found.");
173
174
  }
174
175
  },
175
- deleteUser: async (id) => {
176
+ async deleteUser(id) {
176
177
  const user = await client
177
178
  .select()
178
179
  .from(users)
@@ -181,7 +182,7 @@ export function mySqlDrizzleAdapter(client) {
181
182
  await client.delete(users).where(eq(users.id, id));
182
183
  return user;
183
184
  },
184
- unlinkAccount: async (account) => {
185
+ async unlinkAccount(account) {
185
186
  await client
186
187
  .delete(accounts)
187
188
  .where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));