@auth/drizzle-adapter 0.0.0-manual.94678711 → 0.1.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/lib/mysql.js +14 -14
- package/lib/pg.js +14 -14
- package/lib/sqlite.js +14 -14
- package/package.json +2 -2
- package/src/lib/mysql.ts +14 -14
- package/src/lib/pg.ts +14 -14
- package/src/lib/sqlite.ts +14 -14
package/lib/mysql.js
CHANGED
|
@@ -46,7 +46,7 @@ export const verificationTokens = mysqlTable("verificationToken", {
|
|
|
46
46
|
export const schema = { users, accounts, sessions, verificationTokens };
|
|
47
47
|
export function mySqlDrizzleAdapter(client) {
|
|
48
48
|
return {
|
|
49
|
-
|
|
49
|
+
async createUser(data) {
|
|
50
50
|
const id = crypto.randomUUID();
|
|
51
51
|
await client.insert(users).values({ ...data, id });
|
|
52
52
|
return await client
|
|
@@ -55,7 +55,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
55
55
|
.where(eq(users.id, id))
|
|
56
56
|
.then((res) => res[0]);
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
async getUser(data) {
|
|
59
59
|
const thing = (await client
|
|
60
60
|
.select()
|
|
61
61
|
.from(users)
|
|
@@ -63,7 +63,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
63
63
|
.then((res) => res[0])) ?? null;
|
|
64
64
|
return thing;
|
|
65
65
|
},
|
|
66
|
-
|
|
66
|
+
async getUserByEmail(data) {
|
|
67
67
|
const user = (await client
|
|
68
68
|
.select()
|
|
69
69
|
.from(users)
|
|
@@ -71,7 +71,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
71
71
|
.then((res) => res[0])) ?? null;
|
|
72
72
|
return user;
|
|
73
73
|
},
|
|
74
|
-
|
|
74
|
+
async createSession(data) {
|
|
75
75
|
await client.insert(sessions).values(data);
|
|
76
76
|
return await client
|
|
77
77
|
.select()
|
|
@@ -79,7 +79,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
79
79
|
.where(eq(sessions.sessionToken, data.sessionToken))
|
|
80
80
|
.then((res) => res[0]);
|
|
81
81
|
},
|
|
82
|
-
|
|
82
|
+
async getSessionAndUser(data) {
|
|
83
83
|
const sessionAndUser = (await client
|
|
84
84
|
.select({
|
|
85
85
|
session: sessions,
|
|
@@ -91,7 +91,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
91
91
|
.then((res) => res[0])) ?? null;
|
|
92
92
|
return sessionAndUser;
|
|
93
93
|
},
|
|
94
|
-
|
|
94
|
+
async updateUser(data) {
|
|
95
95
|
if (!data.id) {
|
|
96
96
|
throw new Error("No user id.");
|
|
97
97
|
}
|
|
@@ -102,7 +102,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
102
102
|
.where(eq(users.id, data.id))
|
|
103
103
|
.then((res) => res[0]);
|
|
104
104
|
},
|
|
105
|
-
|
|
105
|
+
async updateSession(data) {
|
|
106
106
|
await client
|
|
107
107
|
.update(sessions)
|
|
108
108
|
.set(data)
|
|
@@ -113,13 +113,13 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
113
113
|
.where(eq(sessions.sessionToken, data.sessionToken))
|
|
114
114
|
.then((res) => res[0]);
|
|
115
115
|
},
|
|
116
|
-
|
|
116
|
+
async linkAccount(rawAccount) {
|
|
117
117
|
await client
|
|
118
118
|
.insert(accounts)
|
|
119
119
|
.values(rawAccount)
|
|
120
120
|
.then((res) => res[0]);
|
|
121
121
|
},
|
|
122
|
-
|
|
122
|
+
async getUserByAccount(account) {
|
|
123
123
|
const dbAccount = (await client
|
|
124
124
|
.select()
|
|
125
125
|
.from(accounts)
|
|
@@ -131,7 +131,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
131
131
|
}
|
|
132
132
|
return dbAccount.users;
|
|
133
133
|
},
|
|
134
|
-
|
|
134
|
+
async deleteSession(sessionToken) {
|
|
135
135
|
const session = (await client
|
|
136
136
|
.select()
|
|
137
137
|
.from(sessions)
|
|
@@ -142,7 +142,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
142
142
|
.where(eq(sessions.sessionToken, sessionToken));
|
|
143
143
|
return session;
|
|
144
144
|
},
|
|
145
|
-
|
|
145
|
+
async createVerificationToken(token) {
|
|
146
146
|
await client.insert(verificationTokens).values(token);
|
|
147
147
|
return await client
|
|
148
148
|
.select()
|
|
@@ -150,7 +150,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
150
150
|
.where(eq(verificationTokens.identifier, token.identifier))
|
|
151
151
|
.then((res) => res[0]);
|
|
152
152
|
},
|
|
153
|
-
|
|
153
|
+
async useVerificationToken(token) {
|
|
154
154
|
try {
|
|
155
155
|
const deletedToken = (await client
|
|
156
156
|
.select()
|
|
@@ -166,7 +166,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
166
166
|
throw new Error("No verification token found.");
|
|
167
167
|
}
|
|
168
168
|
},
|
|
169
|
-
|
|
169
|
+
async deleteUser(id) {
|
|
170
170
|
const user = await client
|
|
171
171
|
.select()
|
|
172
172
|
.from(users)
|
|
@@ -175,7 +175,7 @@ export function mySqlDrizzleAdapter(client) {
|
|
|
175
175
|
await client.delete(users).where(eq(users.id, id));
|
|
176
176
|
return user;
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
async unlinkAccount(account) {
|
|
179
179
|
await client
|
|
180
180
|
.delete(accounts)
|
|
181
181
|
.where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));
|
package/lib/pg.js
CHANGED
|
@@ -41,35 +41,35 @@ export const verificationTokens = pgTable("verificationToken", {
|
|
|
41
41
|
export const schema = { users, accounts, sessions, verificationTokens };
|
|
42
42
|
export function pgDrizzleAdapter(client) {
|
|
43
43
|
return {
|
|
44
|
-
|
|
44
|
+
async createUser(data) {
|
|
45
45
|
return await client
|
|
46
46
|
.insert(users)
|
|
47
47
|
.values({ ...data, id: crypto.randomUUID() })
|
|
48
48
|
.returning()
|
|
49
49
|
.then((res) => res[0] ?? null);
|
|
50
50
|
},
|
|
51
|
-
|
|
51
|
+
async getUser(data) {
|
|
52
52
|
return await client
|
|
53
53
|
.select()
|
|
54
54
|
.from(users)
|
|
55
55
|
.where(eq(users.id, data))
|
|
56
56
|
.then((res) => res[0] ?? null);
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
async getUserByEmail(data) {
|
|
59
59
|
return await client
|
|
60
60
|
.select()
|
|
61
61
|
.from(users)
|
|
62
62
|
.where(eq(users.email, data))
|
|
63
63
|
.then((res) => res[0] ?? null);
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
async createSession(data) {
|
|
66
66
|
return await client
|
|
67
67
|
.insert(sessions)
|
|
68
68
|
.values(data)
|
|
69
69
|
.returning()
|
|
70
70
|
.then((res) => res[0]);
|
|
71
71
|
},
|
|
72
|
-
|
|
72
|
+
async getSessionAndUser(data) {
|
|
73
73
|
return await client
|
|
74
74
|
.select({
|
|
75
75
|
session: sessions,
|
|
@@ -80,7 +80,7 @@ export function pgDrizzleAdapter(client) {
|
|
|
80
80
|
.innerJoin(users, eq(users.id, sessions.userId))
|
|
81
81
|
.then((res) => res[0] ?? null);
|
|
82
82
|
},
|
|
83
|
-
|
|
83
|
+
async updateUser(data) {
|
|
84
84
|
if (!data.id) {
|
|
85
85
|
throw new Error("No user id.");
|
|
86
86
|
}
|
|
@@ -91,7 +91,7 @@ export function pgDrizzleAdapter(client) {
|
|
|
91
91
|
.returning()
|
|
92
92
|
.then((res) => res[0]);
|
|
93
93
|
},
|
|
94
|
-
|
|
94
|
+
async updateSession(data) {
|
|
95
95
|
return await client
|
|
96
96
|
.update(sessions)
|
|
97
97
|
.set(data)
|
|
@@ -99,7 +99,7 @@ export function pgDrizzleAdapter(client) {
|
|
|
99
99
|
.returning()
|
|
100
100
|
.then((res) => res[0]);
|
|
101
101
|
},
|
|
102
|
-
|
|
102
|
+
async linkAccount(rawAccount) {
|
|
103
103
|
const updatedAccount = await client
|
|
104
104
|
.insert(accounts)
|
|
105
105
|
.values(rawAccount)
|
|
@@ -119,7 +119,7 @@ export function pgDrizzleAdapter(client) {
|
|
|
119
119
|
};
|
|
120
120
|
return account;
|
|
121
121
|
},
|
|
122
|
-
|
|
122
|
+
async getUserByAccount(account) {
|
|
123
123
|
const dbAccount = (await client
|
|
124
124
|
.select()
|
|
125
125
|
.from(accounts)
|
|
@@ -131,7 +131,7 @@ export function pgDrizzleAdapter(client) {
|
|
|
131
131
|
}
|
|
132
132
|
return dbAccount.users;
|
|
133
133
|
},
|
|
134
|
-
|
|
134
|
+
async deleteSession(sessionToken) {
|
|
135
135
|
const session = await client
|
|
136
136
|
.delete(sessions)
|
|
137
137
|
.where(eq(sessions.sessionToken, sessionToken))
|
|
@@ -139,14 +139,14 @@ export function pgDrizzleAdapter(client) {
|
|
|
139
139
|
.then((res) => res[0] ?? null);
|
|
140
140
|
return session;
|
|
141
141
|
},
|
|
142
|
-
|
|
142
|
+
async createVerificationToken(token) {
|
|
143
143
|
return await client
|
|
144
144
|
.insert(verificationTokens)
|
|
145
145
|
.values(token)
|
|
146
146
|
.returning()
|
|
147
147
|
.then((res) => res[0]);
|
|
148
148
|
},
|
|
149
|
-
|
|
149
|
+
async useVerificationToken(token) {
|
|
150
150
|
try {
|
|
151
151
|
return await client
|
|
152
152
|
.delete(verificationTokens)
|
|
@@ -158,14 +158,14 @@ export function pgDrizzleAdapter(client) {
|
|
|
158
158
|
throw new Error("No verification token found.");
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
|
-
|
|
161
|
+
async deleteUser(id) {
|
|
162
162
|
await client
|
|
163
163
|
.delete(users)
|
|
164
164
|
.where(eq(users.id, id))
|
|
165
165
|
.returning()
|
|
166
166
|
.then((res) => res[0] ?? null);
|
|
167
167
|
},
|
|
168
|
-
|
|
168
|
+
async unlinkAccount(account) {
|
|
169
169
|
const { type, provider, providerAccountId, userId } = await client
|
|
170
170
|
.delete(accounts)
|
|
171
171
|
.where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)))
|
package/lib/sqlite.js
CHANGED
|
@@ -41,23 +41,23 @@ export const verificationTokens = sqliteTable("verificationToken", {
|
|
|
41
41
|
export const schema = { users, accounts, sessions, verificationTokens };
|
|
42
42
|
export function SQLiteDrizzleAdapter(client) {
|
|
43
43
|
return {
|
|
44
|
-
createUser
|
|
44
|
+
createUser(data) {
|
|
45
45
|
return client
|
|
46
46
|
.insert(users)
|
|
47
47
|
.values({ ...data, id: crypto.randomUUID() })
|
|
48
48
|
.returning()
|
|
49
49
|
.get();
|
|
50
50
|
},
|
|
51
|
-
getUser
|
|
51
|
+
getUser(data) {
|
|
52
52
|
return client.select().from(users).where(eq(users.id, data)).get() ?? null;
|
|
53
53
|
},
|
|
54
|
-
getUserByEmail
|
|
54
|
+
getUserByEmail(data) {
|
|
55
55
|
return (client.select().from(users).where(eq(users.email, data)).get() ?? null);
|
|
56
56
|
},
|
|
57
|
-
createSession
|
|
57
|
+
createSession(data) {
|
|
58
58
|
return client.insert(sessions).values(data).returning().get();
|
|
59
59
|
},
|
|
60
|
-
getSessionAndUser
|
|
60
|
+
getSessionAndUser(data) {
|
|
61
61
|
return (client
|
|
62
62
|
.select({
|
|
63
63
|
session: sessions,
|
|
@@ -68,7 +68,7 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
68
68
|
.innerJoin(users, eq(users.id, sessions.userId))
|
|
69
69
|
.get() ?? null);
|
|
70
70
|
},
|
|
71
|
-
updateUser
|
|
71
|
+
updateUser(data) {
|
|
72
72
|
if (!data.id) {
|
|
73
73
|
throw new Error("No user id.");
|
|
74
74
|
}
|
|
@@ -79,7 +79,7 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
79
79
|
.returning()
|
|
80
80
|
.get();
|
|
81
81
|
},
|
|
82
|
-
updateSession
|
|
82
|
+
updateSession(data) {
|
|
83
83
|
return client
|
|
84
84
|
.update(sessions)
|
|
85
85
|
.set(data)
|
|
@@ -87,7 +87,7 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
87
87
|
.returning()
|
|
88
88
|
.get();
|
|
89
89
|
},
|
|
90
|
-
linkAccount
|
|
90
|
+
linkAccount(rawAccount) {
|
|
91
91
|
const updatedAccount = client
|
|
92
92
|
.insert(accounts)
|
|
93
93
|
.values(rawAccount)
|
|
@@ -106,7 +106,7 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
106
106
|
};
|
|
107
107
|
return account;
|
|
108
108
|
},
|
|
109
|
-
getUserByAccount
|
|
109
|
+
getUserByAccount(account) {
|
|
110
110
|
const results = client
|
|
111
111
|
.select()
|
|
112
112
|
.from(accounts)
|
|
@@ -115,17 +115,17 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
115
115
|
.get();
|
|
116
116
|
return results?.users ?? null;
|
|
117
117
|
},
|
|
118
|
-
deleteSession
|
|
118
|
+
deleteSession(sessionToken) {
|
|
119
119
|
return (client
|
|
120
120
|
.delete(sessions)
|
|
121
121
|
.where(eq(sessions.sessionToken, sessionToken))
|
|
122
122
|
.returning()
|
|
123
123
|
.get() ?? null);
|
|
124
124
|
},
|
|
125
|
-
createVerificationToken
|
|
125
|
+
createVerificationToken(token) {
|
|
126
126
|
return client.insert(verificationTokens).values(token).returning().get();
|
|
127
127
|
},
|
|
128
|
-
useVerificationToken
|
|
128
|
+
useVerificationToken(token) {
|
|
129
129
|
try {
|
|
130
130
|
return (client
|
|
131
131
|
.delete(verificationTokens)
|
|
@@ -137,10 +137,10 @@ export function SQLiteDrizzleAdapter(client) {
|
|
|
137
137
|
throw new Error("No verification token found.");
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
|
-
deleteUser
|
|
140
|
+
deleteUser(id) {
|
|
141
141
|
return client.delete(users).where(eq(users.id, id)).returning().get();
|
|
142
142
|
},
|
|
143
|
-
unlinkAccount
|
|
143
|
+
unlinkAccount(account) {
|
|
144
144
|
client
|
|
145
145
|
.delete(accounts)
|
|
146
146
|
.where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth/drizzle-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Drizzle adapter for Auth.js.",
|
|
5
5
|
"homepage": "https://authjs.dev",
|
|
6
6
|
"repository": "https://github.com/nextauthjs/next-auth",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@auth/core": "0.10.
|
|
39
|
+
"@auth/core": "0.10.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/better-sqlite3": "^7.6.4",
|
package/src/lib/mysql.ts
CHANGED
|
@@ -72,7 +72,7 @@ export function mySqlDrizzleAdapter(
|
|
|
72
72
|
client: MySql2Database<Record<string, never>>
|
|
73
73
|
): Adapter {
|
|
74
74
|
return {
|
|
75
|
-
|
|
75
|
+
async createUser(data) {
|
|
76
76
|
const id = crypto.randomUUID()
|
|
77
77
|
|
|
78
78
|
await client.insert(users).values({ ...data, id })
|
|
@@ -83,7 +83,7 @@ export function mySqlDrizzleAdapter(
|
|
|
83
83
|
.where(eq(users.id, id))
|
|
84
84
|
.then((res) => res[0])
|
|
85
85
|
},
|
|
86
|
-
|
|
86
|
+
async getUser(data) {
|
|
87
87
|
const thing =
|
|
88
88
|
(await client
|
|
89
89
|
.select()
|
|
@@ -93,7 +93,7 @@ export function mySqlDrizzleAdapter(
|
|
|
93
93
|
|
|
94
94
|
return thing
|
|
95
95
|
},
|
|
96
|
-
|
|
96
|
+
async getUserByEmail(data) {
|
|
97
97
|
const user =
|
|
98
98
|
(await client
|
|
99
99
|
.select()
|
|
@@ -103,7 +103,7 @@ export function mySqlDrizzleAdapter(
|
|
|
103
103
|
|
|
104
104
|
return user
|
|
105
105
|
},
|
|
106
|
-
|
|
106
|
+
async createSession(data) {
|
|
107
107
|
await client.insert(sessions).values(data)
|
|
108
108
|
|
|
109
109
|
return await client
|
|
@@ -112,7 +112,7 @@ export function mySqlDrizzleAdapter(
|
|
|
112
112
|
.where(eq(sessions.sessionToken, data.sessionToken))
|
|
113
113
|
.then((res) => res[0])
|
|
114
114
|
},
|
|
115
|
-
|
|
115
|
+
async getSessionAndUser(data) {
|
|
116
116
|
const sessionAndUser =
|
|
117
117
|
(await client
|
|
118
118
|
.select({
|
|
@@ -126,7 +126,7 @@ export function mySqlDrizzleAdapter(
|
|
|
126
126
|
|
|
127
127
|
return sessionAndUser
|
|
128
128
|
},
|
|
129
|
-
|
|
129
|
+
async updateUser(data) {
|
|
130
130
|
if (!data.id) {
|
|
131
131
|
throw new Error("No user id.")
|
|
132
132
|
}
|
|
@@ -139,7 +139,7 @@ export function mySqlDrizzleAdapter(
|
|
|
139
139
|
.where(eq(users.id, data.id))
|
|
140
140
|
.then((res) => res[0])
|
|
141
141
|
},
|
|
142
|
-
|
|
142
|
+
async updateSession(data) {
|
|
143
143
|
await client
|
|
144
144
|
.update(sessions)
|
|
145
145
|
.set(data)
|
|
@@ -151,13 +151,13 @@ export function mySqlDrizzleAdapter(
|
|
|
151
151
|
.where(eq(sessions.sessionToken, data.sessionToken))
|
|
152
152
|
.then((res) => res[0])
|
|
153
153
|
},
|
|
154
|
-
|
|
154
|
+
async linkAccount(rawAccount) {
|
|
155
155
|
await client
|
|
156
156
|
.insert(accounts)
|
|
157
157
|
.values(rawAccount)
|
|
158
158
|
.then((res) => res[0])
|
|
159
159
|
},
|
|
160
|
-
|
|
160
|
+
async getUserByAccount(account) {
|
|
161
161
|
const dbAccount =
|
|
162
162
|
(await client
|
|
163
163
|
.select()
|
|
@@ -177,7 +177,7 @@ export function mySqlDrizzleAdapter(
|
|
|
177
177
|
|
|
178
178
|
return dbAccount.users
|
|
179
179
|
},
|
|
180
|
-
|
|
180
|
+
async deleteSession(sessionToken) {
|
|
181
181
|
const session =
|
|
182
182
|
(await client
|
|
183
183
|
.select()
|
|
@@ -191,7 +191,7 @@ export function mySqlDrizzleAdapter(
|
|
|
191
191
|
|
|
192
192
|
return session
|
|
193
193
|
},
|
|
194
|
-
|
|
194
|
+
async createVerificationToken(token) {
|
|
195
195
|
await client.insert(verificationTokens).values(token)
|
|
196
196
|
|
|
197
197
|
return await client
|
|
@@ -200,7 +200,7 @@ export function mySqlDrizzleAdapter(
|
|
|
200
200
|
.where(eq(verificationTokens.identifier, token.identifier))
|
|
201
201
|
.then((res) => res[0])
|
|
202
202
|
},
|
|
203
|
-
|
|
203
|
+
async useVerificationToken(token) {
|
|
204
204
|
try {
|
|
205
205
|
const deletedToken =
|
|
206
206
|
(await client
|
|
@@ -228,7 +228,7 @@ export function mySqlDrizzleAdapter(
|
|
|
228
228
|
throw new Error("No verification token found.")
|
|
229
229
|
}
|
|
230
230
|
},
|
|
231
|
-
|
|
231
|
+
async deleteUser(id) {
|
|
232
232
|
const user = await client
|
|
233
233
|
.select()
|
|
234
234
|
.from(users)
|
|
@@ -239,7 +239,7 @@ export function mySqlDrizzleAdapter(
|
|
|
239
239
|
|
|
240
240
|
return user
|
|
241
241
|
},
|
|
242
|
-
|
|
242
|
+
async unlinkAccount(account) {
|
|
243
243
|
await client
|
|
244
244
|
.delete(accounts)
|
|
245
245
|
.where(
|
package/src/lib/pg.ts
CHANGED
|
@@ -67,35 +67,35 @@ export function pgDrizzleAdapter(
|
|
|
67
67
|
client: PostgresJsDatabase<Record<string, never>>
|
|
68
68
|
): Adapter {
|
|
69
69
|
return {
|
|
70
|
-
|
|
70
|
+
async createUser(data) {
|
|
71
71
|
return await client
|
|
72
72
|
.insert(users)
|
|
73
73
|
.values({ ...data, id: crypto.randomUUID() })
|
|
74
74
|
.returning()
|
|
75
75
|
.then((res) => res[0] ?? null)
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
async getUser(data) {
|
|
78
78
|
return await client
|
|
79
79
|
.select()
|
|
80
80
|
.from(users)
|
|
81
81
|
.where(eq(users.id, data))
|
|
82
82
|
.then((res) => res[0] ?? null)
|
|
83
83
|
},
|
|
84
|
-
|
|
84
|
+
async getUserByEmail(data) {
|
|
85
85
|
return await client
|
|
86
86
|
.select()
|
|
87
87
|
.from(users)
|
|
88
88
|
.where(eq(users.email, data))
|
|
89
89
|
.then((res) => res[0] ?? null)
|
|
90
90
|
},
|
|
91
|
-
|
|
91
|
+
async createSession(data) {
|
|
92
92
|
return await client
|
|
93
93
|
.insert(sessions)
|
|
94
94
|
.values(data)
|
|
95
95
|
.returning()
|
|
96
96
|
.then((res) => res[0])
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
async getSessionAndUser(data) {
|
|
99
99
|
return await client
|
|
100
100
|
.select({
|
|
101
101
|
session: sessions,
|
|
@@ -106,7 +106,7 @@ export function pgDrizzleAdapter(
|
|
|
106
106
|
.innerJoin(users, eq(users.id, sessions.userId))
|
|
107
107
|
.then((res) => res[0] ?? null)
|
|
108
108
|
},
|
|
109
|
-
|
|
109
|
+
async updateUser(data) {
|
|
110
110
|
if (!data.id) {
|
|
111
111
|
throw new Error("No user id.")
|
|
112
112
|
}
|
|
@@ -118,7 +118,7 @@ export function pgDrizzleAdapter(
|
|
|
118
118
|
.returning()
|
|
119
119
|
.then((res) => res[0])
|
|
120
120
|
},
|
|
121
|
-
|
|
121
|
+
async updateSession(data) {
|
|
122
122
|
return await client
|
|
123
123
|
.update(sessions)
|
|
124
124
|
.set(data)
|
|
@@ -126,7 +126,7 @@ export function pgDrizzleAdapter(
|
|
|
126
126
|
.returning()
|
|
127
127
|
.then((res) => res[0])
|
|
128
128
|
},
|
|
129
|
-
|
|
129
|
+
async linkAccount(rawAccount) {
|
|
130
130
|
const updatedAccount = await client
|
|
131
131
|
.insert(accounts)
|
|
132
132
|
.values(rawAccount)
|
|
@@ -148,7 +148,7 @@ export function pgDrizzleAdapter(
|
|
|
148
148
|
|
|
149
149
|
return account
|
|
150
150
|
},
|
|
151
|
-
|
|
151
|
+
async getUserByAccount(account) {
|
|
152
152
|
const dbAccount =
|
|
153
153
|
(await client
|
|
154
154
|
.select()
|
|
@@ -168,7 +168,7 @@ export function pgDrizzleAdapter(
|
|
|
168
168
|
|
|
169
169
|
return dbAccount.users
|
|
170
170
|
},
|
|
171
|
-
|
|
171
|
+
async deleteSession(sessionToken) {
|
|
172
172
|
const session = await client
|
|
173
173
|
.delete(sessions)
|
|
174
174
|
.where(eq(sessions.sessionToken, sessionToken))
|
|
@@ -177,14 +177,14 @@ export function pgDrizzleAdapter(
|
|
|
177
177
|
|
|
178
178
|
return session
|
|
179
179
|
},
|
|
180
|
-
|
|
180
|
+
async createVerificationToken(token) {
|
|
181
181
|
return await client
|
|
182
182
|
.insert(verificationTokens)
|
|
183
183
|
.values(token)
|
|
184
184
|
.returning()
|
|
185
185
|
.then((res) => res[0])
|
|
186
186
|
},
|
|
187
|
-
|
|
187
|
+
async useVerificationToken(token) {
|
|
188
188
|
try {
|
|
189
189
|
return await client
|
|
190
190
|
.delete(verificationTokens)
|
|
@@ -200,14 +200,14 @@ export function pgDrizzleAdapter(
|
|
|
200
200
|
throw new Error("No verification token found.")
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
|
-
|
|
203
|
+
async deleteUser(id) {
|
|
204
204
|
await client
|
|
205
205
|
.delete(users)
|
|
206
206
|
.where(eq(users.id, id))
|
|
207
207
|
.returning()
|
|
208
208
|
.then((res) => res[0] ?? null)
|
|
209
209
|
},
|
|
210
|
-
|
|
210
|
+
async unlinkAccount(account) {
|
|
211
211
|
const { type, provider, providerAccountId, userId } = await client
|
|
212
212
|
.delete(accounts)
|
|
213
213
|
.where(
|
package/src/lib/sqlite.ts
CHANGED
|
@@ -66,25 +66,25 @@ export function SQLiteDrizzleAdapter(
|
|
|
66
66
|
client: BaseSQLiteDatabase<any, any>
|
|
67
67
|
): Adapter {
|
|
68
68
|
return {
|
|
69
|
-
createUser
|
|
69
|
+
createUser(data) {
|
|
70
70
|
return client
|
|
71
71
|
.insert(users)
|
|
72
72
|
.values({ ...data, id: crypto.randomUUID() })
|
|
73
73
|
.returning()
|
|
74
74
|
.get()
|
|
75
75
|
},
|
|
76
|
-
getUser
|
|
76
|
+
getUser(data) {
|
|
77
77
|
return client.select().from(users).where(eq(users.id, data)).get() ?? null
|
|
78
78
|
},
|
|
79
|
-
getUserByEmail
|
|
79
|
+
getUserByEmail(data) {
|
|
80
80
|
return (
|
|
81
81
|
client.select().from(users).where(eq(users.email, data)).get() ?? null
|
|
82
82
|
)
|
|
83
83
|
},
|
|
84
|
-
createSession
|
|
84
|
+
createSession(data) {
|
|
85
85
|
return client.insert(sessions).values(data).returning().get()
|
|
86
86
|
},
|
|
87
|
-
getSessionAndUser
|
|
87
|
+
getSessionAndUser(data) {
|
|
88
88
|
return (
|
|
89
89
|
client
|
|
90
90
|
.select({
|
|
@@ -97,7 +97,7 @@ export function SQLiteDrizzleAdapter(
|
|
|
97
97
|
.get() ?? null
|
|
98
98
|
)
|
|
99
99
|
},
|
|
100
|
-
updateUser
|
|
100
|
+
updateUser(data) {
|
|
101
101
|
if (!data.id) {
|
|
102
102
|
throw new Error("No user id.")
|
|
103
103
|
}
|
|
@@ -109,7 +109,7 @@ export function SQLiteDrizzleAdapter(
|
|
|
109
109
|
.returning()
|
|
110
110
|
.get()
|
|
111
111
|
},
|
|
112
|
-
updateSession
|
|
112
|
+
updateSession(data) {
|
|
113
113
|
return client
|
|
114
114
|
.update(sessions)
|
|
115
115
|
.set(data)
|
|
@@ -117,7 +117,7 @@ export function SQLiteDrizzleAdapter(
|
|
|
117
117
|
.returning()
|
|
118
118
|
.get()
|
|
119
119
|
},
|
|
120
|
-
linkAccount
|
|
120
|
+
linkAccount(rawAccount) {
|
|
121
121
|
const updatedAccount = client
|
|
122
122
|
.insert(accounts)
|
|
123
123
|
.values(rawAccount)
|
|
@@ -138,7 +138,7 @@ export function SQLiteDrizzleAdapter(
|
|
|
138
138
|
|
|
139
139
|
return account
|
|
140
140
|
},
|
|
141
|
-
getUserByAccount
|
|
141
|
+
getUserByAccount(account) {
|
|
142
142
|
const results = client
|
|
143
143
|
.select()
|
|
144
144
|
.from(accounts)
|
|
@@ -153,7 +153,7 @@ export function SQLiteDrizzleAdapter(
|
|
|
153
153
|
|
|
154
154
|
return results?.users ?? null
|
|
155
155
|
},
|
|
156
|
-
deleteSession
|
|
156
|
+
deleteSession(sessionToken) {
|
|
157
157
|
return (
|
|
158
158
|
client
|
|
159
159
|
.delete(sessions)
|
|
@@ -162,10 +162,10 @@ export function SQLiteDrizzleAdapter(
|
|
|
162
162
|
.get() ?? null
|
|
163
163
|
)
|
|
164
164
|
},
|
|
165
|
-
createVerificationToken
|
|
165
|
+
createVerificationToken(token) {
|
|
166
166
|
return client.insert(verificationTokens).values(token).returning().get()
|
|
167
167
|
},
|
|
168
|
-
useVerificationToken
|
|
168
|
+
useVerificationToken(token) {
|
|
169
169
|
try {
|
|
170
170
|
return (
|
|
171
171
|
client
|
|
@@ -183,10 +183,10 @@ export function SQLiteDrizzleAdapter(
|
|
|
183
183
|
throw new Error("No verification token found.")
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
|
-
deleteUser
|
|
186
|
+
deleteUser(id) {
|
|
187
187
|
return client.delete(users).where(eq(users.id, id)).returning().get()
|
|
188
188
|
},
|
|
189
|
-
unlinkAccount
|
|
189
|
+
unlinkAccount(account) {
|
|
190
190
|
client
|
|
191
191
|
.delete(accounts)
|
|
192
192
|
.where(
|