omnivore/packages/api/src/services/profile.ts
Hongbo Wu 81b0fc19a2 tidy
2024-07-01 10:49:08 +08:00

21 lines
533 B
TypeScript

import { Profile } from '../entity/profile'
import { User } from '../entity/user'
import { authTrx, getRepository } from '../repository'
export const findProfile = async (user: User): Promise<Profile | null> => {
return getRepository(Profile).findOneBy({ user: { id: user.id } })
}
export const updateProfile = async (
userId: string,
profile: Partial<Profile>
) => {
return authTrx(
(tx) => {
return tx.getRepository(Profile).update({ user: { id: userId } }, profile)
},
{
uid: userId,
}
)
}