Web Dev Cody
Web Dev Cody•4mo ago

Delete all files

Is there an easy way to clear all files in convex storage? I'm doing 20 at a time and I have 1k total.
9 Replies
Convex Bot
Convex Bot•4mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Web Dev Cody
Web Dev CodyOP•4mo ago
hmm yeah I think adding a way to get a list of all id's associated with your project to help find orphaned images would be nice because I had a bug in my code that forgot to delete some images but now I have like 1,000 images I have to manually go through and check if they have a corresponding convex entry this is just on dev, but if this was prod and I had real users, idk what I'd even do like a ctx.storage.paginate or something
Indy
Indy•4mo ago
Yeah this has come up a few times. We have some ideas but haven't had a chance to prioritize them yet. Thanks for the reminder.
lee
lee•4mo ago
can you do ctx.db.system.query("_storage").paginate(opts) ? You can also delete all stored files transactionally with a carefully constructed npx convex import, lmk if you want tips on that 🙂
lee
lee•4mo ago
System Tables | Convex Developer Hub
System tables enable read-only access to metadata for built-in Convex features.
ian
ian•4mo ago
@Web Dev Cody is this what you were looking for?
Web Dev Cody
Web Dev CodyOP•4mo ago
export const listAllFiles = query({
handler: async (ctx) => {
// You can use .paginate() as well
return await ctx.db.system.query("_storage").collect();
},
});
export const listAllFiles = query({
handler: async (ctx) => {
// You can use .paginate() as well
return await ctx.db.system.query("_storage").collect();
},
});
yes, this is perfect sorry for not seeing that 😅
Indy
Indy•4mo ago
Ah I yeah, I should have pointed to this api. I was thinking of a generalized case where we can automatically tell you this. That may not happen for a little while.

Did you find this page helpful?