Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3459290
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:05:18+00:00 2026-05-18T10:05:18+00:00

i am new to mongoDB. I am using mongoDB in web app. I want

  • 0

i am new to mongoDB. I am using mongoDB in web app.

I want to know how to get the value of inner document attribute of a document.

Lets say my JSON is like,

{ "_id" : { "$oid" : "4ceb753a70fdf877ef5113ca"}, "Attrr1" : "value1", "Attr2": {"innerAttr1":"innerValue1", "innerAttr2":"innerValue2"}, "Attr3" : { "innerAttr3" : "innerValue3", "innerAttr4" : "innerValue4"} }

For the above json, how can i get innerValue1 and both innerValue1 & innerValue2.

I tried this, but its not working for me!!!

BasicDBObject innerQuery = new BasicDBObject();
field.put("Attr2.innerAttr1", 1);

Any suggestions would be appreciative!!!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:05:19+00:00Added an answer on May 18, 2026 at 10:05 am

    i am not get you. You need get value or set or add into collection inside of some document?

    As i understand you using some driver for mongo db in java. I am not experienced in mongo driver for java. But i know ho to do this in driver or c#:

    in c# mongo driver for update inner property in collection you need do following:

    var query = Query.Eq("_id", documentId);
    var update = Update.Set("Attr2.innerAttr1",1);
    
    MongoDb.Database.GetCollection("collectionName").Update(query, update);
    

    if query from above code retun one document – innerAttr1 property from Attr2 collection will be update. If i know that query return more than one document and i need update more tha one document i use such code:

    MongoDb.Database.GetCollection("collectionName").Update(query, update, UpdateFlag.Multi);
    

    I belive that the same logic in mongo driver for java.

    Hope this help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web app using Codeigniter and MongoDB. I am trying to
I'm new using MongoDB, and I don't know how to solve the next problem:
I would like to build a new web application using ASP.NET MVC3 and MongoDB.
I'm new to MongoDB and I've used RDBMS for years. Anyway, let's say I
I try to delete document in mongodb using php, I it fails and I
I am thinking of writing a web app in Scala using the Play! framework
I'm considering using mongodb on a new project, but before delving in, I'd like
I'm using MongoDB as a log keeper for my app to then sync mobile
I'm using the MongoDB Java driver, and can't seem to get a query to
I am using Node.js and MongoDB. Let say I have predefined few cities (e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.