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

  • Home
  • SEARCH
  • 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 7996539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:43:56+00:00 2026-06-04T14:43:56+00:00

I have encountered strange behavoir while testing my application. I have a request to

  • 0

I have encountered strange behavoir while testing my application.
I have a request to update multiple documents and increment one of thier fields by 1 (and also decrease other by -1, but dont think that this is the point).

Query = { "_id" : { "$in" : [ObjectId("4fbf8481a975b5237c56f221"),
                             ObjectId("4fbf8481a975b5237c56f222"),
                             ObjectId("4fbf8481a975b5237c56f223")] } };
Update = { "$inc" : { "PartlyCompleted" : -1, "Completed" : 1 } }

The first document updates OK, but two others are not affected.

What could be the reason. Please give me advise where to look.

Some aditional information. I’m using C# official driver. Here is some of the code:

_personsId = new BsonArray();
_personsId.AddRange(personsId.Where(x => DataService.IsIdValid(x)).
                              Select(x => new ObjectId(x)).ToArray());

var query = Query.In("_id", _personsId);
var update = Update.Combine(
                    Update.Inc("Completed", 1 ),
                    Update.Inc("PartlyCompleted", -1));

DataService.PersonSet.Collection.Update(query, update);

I also checked the number of documents returned by the query below, and it is 3:

    var count = DataService.PersonSet.Collection.Count(query);
  • 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-04T14:43:57+00:00Added an answer on June 4, 2026 at 2:43 pm

    By default updates affect only the first matched document.

    So, in your example mongo picks one of those 3 documents and increments counters. To update multiple documents you need to set the UpdateFlags.Multi flag.

    I am curious, do you use this flag in other updates? If yes, why the question? If no, are you sure those updates touch multiple documents at once?

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

Sidebar

Related Questions

I have encountered a strange issue. When I update one of my websites to
I have encountered a problem in my application. I have two forms, one that
I have not programmed C++ for a while and encountered a strange behavior when
I have encountered something very strange, simple WPF application <Window x:Class=ListBoxSelection.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow
I have encountered a strange problem on one of our machines. It is a
I have encountered a strange bug in my application, and I am trying to
I have encountered strange issue. From Activity onStart() I request Bluetooth activation and 120s
I have encountered a strange behavior while executing an sql query on the Oracle
I have encountered the strange problem, that linux c++ compiler includes the files from
We have encountered a very strange class not found problem in our web app

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.