-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclearDatabase.js
More file actions
26 lines (20 loc) · 805 Bytes
/
Copy pathclearDatabase.js
File metadata and controls
26 lines (20 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import Match from '../models/Match.js';
import Standing from '../models/Standing.js';
dotenv.config();
async function clearDB() {
try {
await mongoose.connect(process.env.MONGO_URI || 'mongodb://127.0.0.1:27017/saintbarthvolley');
console.log('✅ Connecté à MongoDB');
const deletedMatches = await Match.deleteMany({});
console.log(`🗑️ ${deletedMatches.deletedCount} matchs supprimés`);
const deletedStandings = await Standing.deleteMany({});
console.log(`🗑️ ${deletedStandings.deletedCount} standings supprimés`);
await mongoose.disconnect();
console.log('✅ Déconnecté de MongoDB');
} catch (err) {
console.error('❌ Erreur lors de la suppression :', err);
}
}
clearDB();