20 lines
664 B
TypeScript
20 lines
664 B
TypeScript
import client, { ensureAuthenticated } from '../lib/directus';
|
|
import { readCollections, deleteCollection } from '@directus/sdk';
|
|
|
|
async function cleanup() {
|
|
await ensureAuthenticated();
|
|
const collections = await (client as any).request(readCollections());
|
|
for (const c of collections) {
|
|
if (!c.collection.startsWith('directus_')) {
|
|
console.log(`Deleting ${c.collection}...`);
|
|
try {
|
|
await (client as any).request(deleteCollection(c.collection));
|
|
} catch (e) {
|
|
console.error(`Failed to delete ${c.collection}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cleanup().catch(console.error);
|