@@ -12,6 +12,7 @@ type File = {
|
||||
}
|
||||
|
||||
export type DirectoryItem = Directory | File
|
||||
export type DirectoryItemKind = DirectoryItem["kind"]
|
||||
|
||||
export async function fetchContent(
|
||||
ctx: QueryCtx,
|
||||
@@ -20,7 +21,9 @@ export async function fetchContent(
|
||||
const [files, directories] = await Promise.all([
|
||||
ctx.db
|
||||
.query("files")
|
||||
.withIndex("byDirectoryId", (q) => q.eq("directoryId", directoryId))
|
||||
.withIndex("byDirectoryId", (q) =>
|
||||
q.eq("directoryId", directoryId).eq("deletedAt", undefined),
|
||||
)
|
||||
.collect(),
|
||||
ctx.db
|
||||
.query("directories")
|
||||
|
13
convex/model/files.ts
Normal file
13
convex/model/files.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { v } from "convex/values"
|
||||
import { mutation } from "../_generated/server"
|
||||
|
||||
export const moveToTrash = mutation({
|
||||
args: {
|
||||
fileId: v.id("files"),
|
||||
},
|
||||
handler: async (ctx, { fileId }) => {
|
||||
await ctx.db.patch(fileId, {
|
||||
deletedAt: new Date().toISOString(),
|
||||
})
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user