MongoDB修改删除数据
将name是mongo的记录的name修改为mongo_new
db.things.update({name:"mongo"},{$set:{name:"mongo_new"}});
我们来查询一下是否改过来了
> db.things.find(); { "_id" : ObjectId("501c7e65ab2f3c46faf8e68b"), "x" : 3 } { "_id" : ObjectId("501c7e5cab2f3c46faf8e68a"), "name" : "mongo_new" }
删除记录
将用户name是mongo_new的记录从集合things中删除
> db.things.remove({name:"mongo_new"});
> db.things.find();
{ "_id" : ObjectId("501c7e65ab2f3c46faf8e68b"), "x" : 3 }