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 7556725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:56:09+00:00 2026-05-30T11:56:09+00:00

How would I select the subdocument author, in the below shown object, without directly

  • 0

How would I select the subdocument author, in the below shown object, without directly accessing it, ie authors[0], so that the result that I get back is {"_id":"4f44af6a024342300e000002", visible: true}?

The object:

{
    _id:     "4f44af6a024342300e000001",
    title:   "A book", 
    created: "2012-02-22T14:12:51.305Z"
    authors: [{"_id":"4f44af6a024342300e000002", visible: true}] 
}

I have been able to update it by doing this, but selecting it seems like a completely different story:

books.update({_id: "4f44af6a024342300e000001",'authors._id': "4f44af6a024342300e000002"}, 
             {$set: {'books.$.visible': true}}, function(err) {
    // ...
});
  • 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-30T11:56:11+00:00Added an answer on May 30, 2026 at 11:56 am

    It is currently not possible (see a similar question with extra details)

    In MongoDB, how does on get the value in a field for an embedded document, but query based on a different value

    In the next version, the aggreation framework could give some step in this direction, but the real solution are the virtual collection.

    For the time being (in short), use an embedded document only if you go through the parent.

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

Sidebar

Related Questions

I would like to select a set of elements that are both of a
I would like to select a row from 2 different tables that are relational.
I'm just wondering what kind of SQL command I could execute that would select
I'm trying to create a call to odata webservice that would select only distinct
Poppler is a classic example of something without documentation that you would prefer be
How should I go about setting up HQL condition that would select all the
I am trying to write a query that would select data from multiple lines
I would select multiple DOM elements using a typical code such as this: $('#ele1,
How would I select all but the last child using CSS3 selectors? For example,
How would I select only the first level .block and not any of the

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.