import { AuthenticatedUser } from "../auth"; import { UpdateUserConfigInput, userConfigModel } from "./userConfig.schema"; export async function createUserConfig(userId: string, tenantId: string) { await userConfigModel.create({ tenantId, userId, config: {} }); } export async function getConfig(user: AuthenticatedUser) { return await userConfigModel.findOne({ tenantId: user.tenantId, userId: user.userId, }); } export async function updateConfig( input: UpdateUserConfigInput, user: AuthenticatedUser ) { return await userConfigModel.findOneAndUpdate( { tenantId: user.tenantId, userId: user.userId }, { ...input, }, { new: true } ); } export async function deleteConfig(userId: string, tenantId: string) { await userConfigModel.deleteOne({ userId: userId, tenantId: tenantId }); }