I'm having great difficulties with something that is probably most basic. I have the following entry in my database
{"_id"=>BSON::ObjectId('4ec2429c85aab65f16fa2700'),
"owner"=>4,
"friends"=>{"mappings"=>{"Test"=>34}},
"friendid"=>"309"}
I'm trying to insert another value into the mappings array. Something like "Testing"=>10
Unfortunately I'm having no luck what so ever when trying a variety of different approaches. Currently I'm trying the below with no success.
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);
I'd appreciate it if someone could tell me what I'm doing wrong. I'm assuming its something really obvious!
P.s I'm using the latest Driver and latest MongoDB