sendou.ink/app/features/team/queries/resetInviteLink.server.ts
2023-01-06 16:33:37 +02:00

14 lines
347 B
TypeScript

import { nanoid } from "nanoid";
import { INVITE_CODE_LENGTH } from "~/constants";
import { sql } from "~/db/sql";
const stm = sql.prepare(/* sql */ `
update "AllTeam"
set "inviteCode" = @inviteCode
where "id" = @teamId
`);
export function resetInviteLink(teamId: number) {
stm.run({ teamId, inviteCode: nanoid(INVITE_CODE_LENGTH) });
}