aboutsummaryrefslogtreecommitdiffstats
path: root/server/db/groups.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-08-03 12:34:55 -0700
committerPinapelz <yukais@pinapelz.com>2026-08-03 12:34:55 -0700
commit1f52e962086856ddd6981139e2d4aca20201e9cb (patch)
treead14f1d320f2fd9ebd8e46a76bf508f003003e89 /server/db/groups.ts
parent0cf9257b388485aba8affbe35e98c588c837df97 (diff)
create group streak schema and db scaffold
Diffstat (limited to 'server/db/groups.ts')
-rw-r--r--server/db/groups.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/db/groups.ts b/server/db/groups.ts
new file mode 100644
index 0000000..1060501
--- /dev/null
+++ b/server/db/groups.ts
@@ -0,0 +1,27 @@
+import { db } from "./index";
+import crypto from "node:crypto";
+
+export function createGroup(name: string) {
+ const id = crypto.randomUUID();
+ const joinCode = crypto
+ .randomBytes(3)
+ .toString("hex")
+ .toUpperCase();
+
+ db.prepare(`
+ INSERT INTO groups
+ (id, name, join_code, created_at)
+ VALUES (?, ?, ?, ?)
+ `).run(
+ id,
+ name,
+ joinCode,
+ Date.now()
+ );
+
+ return {
+ id,
+ name,
+ joinCode
+ };
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage