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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:09:09+00:00 2026-06-18T09:09:09+00:00

I am having a problem where I need to update a specific field found

  • 0

I am having a problem where I need to update a specific field found in arrays contained in a bigger array that match certain criteria as of MongoDB v2.2.3.

I have the following mongodb sample document.

{
  _id: ObjectId("50be30b64983e5100a000009"),
  user_id: 0
  occupied: {
    Greece: [
      {
        user_id: 3,
        deadline: ISODate("2013-02-08T19:19:28Z"),
        fulfilled: false
      },
      {
        user_id: 4,
        deadline: ISODate("2013-02-16T19:19:28Z"),
        fulfilled: false
      }
    ],
    Italy: [
      {
        user_id: 2,
        deadline: ISODate("2013-02-15T19:19:28Z"),
        fulfilled: false
      }
    ]
  }
}

Each country in the occupied array has its own set of arrays.

What I am trying to do is find the document where user_id is 0, search through the occupied.Greece array only for elements that have "deadline": {$gt: ISODate(current-date)} and change their individual “fulfilled” fields to true.

I have tried the $ and $elemMatch operators but they match only one, the first, array element in a query whereas I need it to match all eligible elements by the given criteria and make the update without running the same query multiple times or having to process the arrays client-side.

Is there no server-side solution for generic updates in a single document? I am developing using PHP though a solution to this should be universal.

  • 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-06-18T09:09:11+00:00Added an answer on June 18, 2026 at 9:09 am

    I’m afraid this is not possible. From the documentation:

    Remember that the positional $ operator acts as a placeholder for the first match of the update query selector. [emphasis not mine]

    This is tracked in the MongoDB Jira under SERVER-1243.

    There’s quite a number of related feature requests in the jira, mostly under the topic ‘virtual collections‘.

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

Sidebar

Related Questions

Good day! I am having a problem in showing the data that I need
I'm currently having a problem. I need to update Table A from Table B
I'm having an CSS problem, i need to achieve this article div#comments-wrapper ul.sub-comment:before {
I am having a problem with my Listbox not updating/refresing.I have read here that
I am having problem with some regex expression, I need a regex to check
Update : I have changed this question to be about the specific problem I
I need to provide an auto update feature to my application. I am having
I'm having a problem triggering events on items that have been added to the
I'm having problems with this site I am building. I need a fixed width
I am having some problems with an XML transform and need some help. 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.