您的位置:首页 > 数据库 > Mongodb

Mongodb中在已有Colloection插入/更新相关域值

2015-07-27 18:56 761 查看
[{
"confident" : "no",
"score" : 0.327355,
"label" : "/business and industrial"
}, {
"confident" : "no",
"score" : 0.207099,
"label" : "/automotive and vehicles/certified pre-owned"
}, {
"confident" : "no",
"score" : 0.128601,
"label" : "/technology and computing/internet technology/social network"
}]

Java Code:

  BasicDBList dblist = new BasicDBList();

  // 追加的方式

  dblist.add(new BasicDBObject("label", topic.getField("categoryName")).append("score", topic.getField("score")));

  updatedValue.put("calais", dblist);

  DBObject updateSetValue = new BasicDBObject("$set", updatedValue);

  insertdbCollection.update(updateCondition, updateSetValue);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: