UNPKG

@paroicms/server

Version:
18 lines 716 B
import { type } from "arktype"; const RoleRowAT = type({ role: "string", "+": "reject", }); export async function getAccountRoles(siteContext, accountId) { const rows = await siteContext.cn("PaAccountRole").select("role").where("accountId", accountId); return rows.map((row) => RoleRowAT.assert(row).role); } export async function updateAccountRoles(siteContext, accountId, roles) { await siteContext.cn.transaction(async (tx) => { await tx("PaAccountRole").where("accountId", accountId).delete(); if (roles.length > 0) { await tx("PaAccountRole").insert(roles.map((role) => ({ accountId, role }))); } }); } //# sourceMappingURL=account-role.queries.js.map