javascript - How to delete a message in mongoDB using js
给我你的怀抱
给我你的怀抱 2017-06-08 11:02:02
0
2
754
  1. mongoDB stores articles

  2. A message has time, title, content, publisher and _id

  3. Using JavaScript

  4. The express framework of node.js used

  5. Please post the code Thank you

给我你的怀抱
给我你的怀抱

reply all(2)
世界只因有你

May I ask what middleware the poster uses to operate mongodb? Here I will write it according to 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){});

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template