31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
const sdk = require('node-appwrite');
|
|
|
|
const client = new sdk.Client()
|
|
.setEndpoint('https://appwrite.almeira.com.co/v1')
|
|
.setProject('69b84df5003bd8957c5c')
|
|
.setKey('standard_cce3cdb866ea6433888d40cedd24dc45987372308fdc3dd0697de08648c0e5c7e04b02c3bcee271403fd656b00a5820f04c08b51631284a6e8a3582d8aed2aa33234f3c29cc777e9b162eb54810b789251b0d006a9a3b081ebc2da53b9baa94614b124b3508ad849fd9a4187cc6094f506d4b57f409b69d9562a74df594f3ec3');
|
|
|
|
const dbs = new sdk.Databases(client);
|
|
const DB_ID = 'sneakers_multistore_db';
|
|
|
|
async function clean() {
|
|
const colls = ['payment_methods', 'store_settings'];
|
|
for (const coll of colls) {
|
|
console.log(`Checking attributes for ${coll}...`);
|
|
const res = await dbs.listAttributes(DB_ID, coll);
|
|
for (const a of res.attributes) {
|
|
if (a.status === 'failed') {
|
|
console.log(`Deleting failed attribute: ${coll}.${a.key}`);
|
|
try {
|
|
await dbs.deleteAttribute(DB_ID, coll, a.key);
|
|
console.log(` -> Deleted ${a.key}`);
|
|
} catch (e) {
|
|
console.error(` -> Failed to delete ${a.key}:`, e.message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
clean().catch(console.error);
|