Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-769

Facing issue while inserting data into mongodb

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • None
    • 2.6.5
    • API
    • None
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            naveen.coolest Naveen Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: