mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-15 22:38:47 +00:00
토큰에 클라이언트 정보를 함께 저장하도록 변경
This commit is contained in:
17
src/lib/server/db/client.ts
Normal file
17
src/lib/server/db/client.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import db from "./drizzle";
|
||||
import { client, userClient } from "./schema";
|
||||
|
||||
export const getClientByPubKey = async (pubKey: string) => {
|
||||
const clients = await db.select().from(client).where(eq(client.pubKey, pubKey)).execute();
|
||||
return clients[0] ?? null;
|
||||
};
|
||||
|
||||
export const getUserClient = async (userId: number, clientId: number) => {
|
||||
const userClients = await db
|
||||
.select()
|
||||
.from(userClient)
|
||||
.where(and(eq(userClient.userId, userId), eq(userClient.clientId, clientId)))
|
||||
.execute();
|
||||
return userClients[0] ?? null;
|
||||
};
|
||||
Reference in New Issue
Block a user