Update1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18Mongo mg = new Mongo("localhost", 27017);
// get db
db = mg.getDB("CRUD");
// get collection
dc = db.getCollection("test");
//Update
BasicDBObject query = new BasicDBObject();
query.put("name", "hulu22");
query.put("title", "PO");
BasicDBObject newDoc = new BasicDBObject();
newDoc.put("$set", new BasicDBObject("title", "PM").append("name", "hulu22"));// $unset: Removes the specified field from a document.
dc.update(query, newDoc);
dc.update(query, newDoc, false, false);
dc.updateMulti(query, newDoc);
使用Java操作MongoDB - Update
欢迎您扫一扫上面的微信公众号,订阅我的博客!
分享创造价值,您的支持将鼓励我继续前行!
- Post link: http://izheyi.com/2014/12/24/使用Java操作MongoDB-Update/
- Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.