おそらく最も基本的なことで大きな問題を抱えています。データベースに次のエントリがあります
{"_id"=>BSON::ObjectId('4ec2429c85aab65f16fa2700'),
"owner"=>4,
"friends"=>{"mappings"=>{"Test"=>34}},
"friendid"=>"309"}
mappings 配列に別の値を挿入しようとしています。「テスト」のようなもの=> 10
残念ながら、さまざまなアプローチを試みても、まったく運がありません。現在、私は以下を試していますが、成功していません。
BasicDBObject updateQuery = new BasicDBObject();
updateQuery.put("owner", owner);
updateQuery.put("friendid", userid);
BasicDBObject updateCommand = new BasicDBObject();
updateCommand.put("$push", new BasicDBObject("friends.mappings",
new BasicDBObject(clustername, clusterid)));
WriteResult result = collection.update(updateQuery, updateCommand,false,true);
誰かが私が間違っていることを教えてくれれば幸いです。私はそれが本当に明白なことだと思っています!
Ps 最新の Driver と最新の MongoDB を使用しています