added file upload handler to tasks

This commit is contained in:
2025-02-14 12:48:24 +05:30
parent a933c25f34
commit 5276f2a6cb
5 changed files with 56 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import {
taskFields,
taskModel,
UpdateTaskInput,
UploadTaskInput,
} from "./task.schema";
export async function createTask(
@@ -227,3 +228,22 @@ export async function searchTasks(params: PageQueryParams, tenantId: string) {
},
};
}
export async function newUpload(
id: string,
newUpload: UploadTaskInput,
user: AuthenticatedUser
) {
return await taskModel.findOneAndUpdate(
{ pid: id, tenantId: user.tenantId },
{
$push: {
documents: {
files: newUpload.files,
createdAt: new Date(),
createdBy: user.userId,
},
},
}
);
}