Files
omnivore/packages/api/src/services/upload_file.ts
2023-10-05 14:30:10 +08:00

25 lines
578 B
TypeScript

import { UploadFile } from '../entity/upload_file'
import { authTrx, getRepository } from '../repository'
export const findUploadFileById = async (id: string) => {
return getRepository(UploadFile).findOne({
where: { id },
relations: {
user: true,
},
})
}
export const setFileUploadComplete = async (id: string, userId?: string) => {
return authTrx(
async (tx) => {
const repo = tx.getRepository(UploadFile)
await repo.update(id, { status: 'COMPLETED' })
return repo.findOneByOrFail({ id })
},
undefined,
userId
)
}