扫码关注官方订阅号
mongoDB存的是文章
一条信息有时间,标题,内容,发表者和_id
用JavaScript实现
用的node.js的express框架
请贴代码 谢谢
敢问楼主用的是什么中间件操作mongodb呢?这里我就按mongoose的写法来吧:
//因为不清楚楼主想要通过什么条件进行删除,通过id肯定不靠谱 //这里通过作者和文章标题进行查询并删除,使用的是findOne值查询一个 Passage.findOneAndRemove({author:"LiMing",title:"helloworld"}).exec();
db.person.remove(“name”:"ziling")
增db.collection("tb2").insert([{"name":"wilson001","age":21},{"name":"wilson002"},{"age":22}],function(err,result){})删db.collection("tb2").remove({"name":"wilson002"},function(err,result){});改db.collection("tb2").update({"name":"wilson001"},{$set:{"age":100}},function(err,result){});查db.collection("tb2").find({"name":"wilson001"}).toArray(function(err,result){});
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
敢问楼主用的是什么中间件操作mongodb呢?这里我就按mongoose的写法来吧:
db.person.remove(“name”:"ziling")
增
db.collection("tb2").insert([{"name":"wilson001","age":21},{"name":"wilson002"},{"age":22}],function(err,result){})
删
db.collection("tb2").remove({"name":"wilson002"},function(err,result){});
改
db.collection("tb2").update({"name":"wilson001"},{$set:{"age":100}},function(err,result){});
查
db.collection("tb2").find({"name":"wilson001"}).toArray(function(err,result){});