[JAVA-769] Facing issue while inserting data into mongodb Created: 24/Feb/13  Updated: 24/Feb/13  Resolved: 24/Feb/13

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Naveen Kumar Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac 10.6.8 OX



 Description   

Hi,

I have an object inside my mongodb like this
{ "_id" : ObjectId("5129d8a4da06f4571f45d1a2"),
"User_Id" : {
"Profile" :

{ "Naveen_009": }

} }.

Now i want to check the profile value is Glamour_009,if result is true i want to insert data like this
"Twitter" :

{ "08 Feb 2013" : [ 11, 10, 0, 1 ], "09 Feb 2013" : [ 890, 546, 35, 309 ], "10 Feb 2013" : [ 728, 458, 30, 240 ] }

.

To do this am using following logic.
BasicDBObject query =new BasicDBObject().append("009.Profile","Glamour_009");
BasicDBObject newDocument3 = new BasicDBObject().append("$set", new BasicDBObject(key,arrayObj));
collection.findAndModify(query, newDocument3);

But as a result am getting result in some unneeded manner like this

{ "009" : { "Profile" : {"Glamour_009": }

,
"08 Feb 2013" : [ 1253, 857, 55, 341 ],
"09 Feb 2013" : [ 890, 546, 35, 309 ],
"10 Feb 2013" : [ 728, 458, 30, 240 ] },
"_id" : ObjectId("5129bf1dda06f4709d2b98ee") }

Help me to get required result if u suggest some books it il be help full too.



 Comments   
Comment by Naveen Kumar [ 24/Feb/13 ]

My Mistake
Result am geting is

{ "User_Id" : { "Profile" : {"Naveen_009": }

,
"08 Feb 2013" : [ 1253, 857, 55, 341 ],
"09 Feb 2013" : [ 890, 546, 35, 309 ],
"10 Feb 2013" : [ 728, 458, 30, 240 ] },
"_id" : ObjectId("5129bf1dda06f4709d2b98ee") }

Generated at Thu Feb 08 08:53:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.