1
我需要兩個才能將新項目添加到mongo db中的現有數據。在java中爲mongo的現有集合添加新數據
這是mongo db我有以下數據。
{
"_id" : ObjectId("53ce11e7d0881d32d9fa935f"),
"name" : "massive riots",
"lastFeachedTime" : "Jul 15, 2014 12:55:27 PM"
}
在這裏我必須找到基於名稱的數據,我必須添加另外兩個項目兩個它。
這是我的代碼。
DBObject queryObject = new BasicDBObject().append("name", keyword);
if (null == newFetchTime) {
}
DBObject updateObject = new BasicDBObject();
updateObject.put("nextPageToken", nextPageToken);
updateObject.put("prevPageToken", prevPageToken);
Utils utils = new Utils();
DBCollection collection = utils.getStaging().getCollection("test");
collection.update(queryObject, updateObject, true, false);
但我做更新現有值得到刪除和新的數據得到補充。
任何人都可以告訴我如何將項目添加到mongo db中的現有數據。