// MongoDB 删除集合中所有文档
db.collection('collectionName').deleteMany({})
.then(result => {
console.log(`已删除 ${result.deletedCount} 个文档`);
})
.catch(error => {
console.error('删除失败:', error);
});
// 删除整个集合
db.collection('collectionName').drop()
.then(result => {
console.log('集合已删除');
})
.catch(error => {
console.error('删除集合失败:', error);
});