1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
interface UpsertEmailSubscriberParams {
name: string;
email: string;
token: string;
}
export async function upsertEmailSubscriber({ name, email, token }) {
return sqlite.execute({
sql: `
INSERT INTO subscribers (name, email, verification_token)
VALUES (?, ?, ?)
ON CONFLICT(email)
DO UPDATE SET
name = excluded.name,
verification_token = excluded.verification_token,
subscribed_at = CURRENT_TIMESTAMP;
`,
args: [name, email, token],
});
}