* Clean up database between benchmarks
()
| 78 | * Clean up database between benchmarks |
| 79 | */ |
| 80 | async function cleanupDatabase() { |
| 81 | try { |
| 82 | if (!mongoClient) { |
| 83 | mongoClient = await MongoClient.connect(MONGODB_URI); |
| 84 | } |
| 85 | const db = mongoClient.db(); |
| 86 | const collections = await db.listCollections().toArray(); |
| 87 | |
| 88 | for (const collection of collections) { |
| 89 | if (!collection.name.startsWith('system.')) { |
| 90 | await db.collection(collection.name).deleteMany({}); |
| 91 | } |
| 92 | } |
| 93 | } catch (error) { |
| 94 | throw new Error(`Failed to cleanup database: ${error.message}`); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Reset Parse SDK to use the default server |
no test coverage detected