update file endpoints

This commit is contained in:
2025-04-15 13:17:53 +05:30
parent e7194e22c4
commit 93e77d5e16
2 changed files with 3 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ const createFileInput = z.object({
const updateFileInput = z.object({ const updateFileInput = z.object({
parentId: z.string().optional(), parentId: z.string().optional(),
name: z.string().optional(), name: z.string().optional(),
root: z.boolean().optional(),
}); });
const downloadFileResponse = z.object({ const downloadFileResponse = z.object({

View File

@@ -27,7 +27,7 @@ export async function createFile(
return await fileModel.create({ return await fileModel.create({
tenantId: user.tenantId, tenantId: user.tenantId,
pid: generateId(), pid: generateId(),
status: input.mimeType == "folder" ? "done" : "penidng", status: input.mimeType == "folder" ? "done" : "pending",
createdAt: new Date(), createdAt: new Date(),
createdBy: user.userId, createdBy: user.userId,
isDeleted: false, isDeleted: false,
@@ -67,7 +67,7 @@ export async function updateFile(
input: UpdateFileInput, input: UpdateFileInput,
tenantId: string tenantId: string
) { ) {
if (input.parentId) { if (input.parentId && !input.root) {
const parentInDb = await fileModel.findOne({ const parentInDb = await fileModel.findOne({
$and: [ $and: [
{ tenantId: tenantId }, { tenantId: tenantId },