使用express框架和mongoose在MongoDB删除数据

使用remove()删除数据

remove({},function(err,doc){})  // 删除所有数据

remove({age:18},function(err,doc){}); //删除指定条件的数据

User.remove({},function(err,doc){
    if(err){
        console.log(err);
        
    }else{
        console.log(doc);
        
    }
});
User.remove({age:12},function(err,doc){
    if(err){
        console.log(err);
        
    }else{
        console.log(doc);
        
    }
});
原文地址:https://www.cnblogs.com/luguankun/p/10265019.html