update file endpoints
This commit is contained in:
@@ -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({
|
||||||
|
|||||||
@@ -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 },
|
||||||
|
|||||||
Reference in New Issue
Block a user