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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:41:04+00:00 2026-06-14T17:41:04+00:00

I have a MongoDB collection as follows: comment_id (number) comment_title (text) score (number) time_score

  • 0

I have a MongoDB collection as follows:

comment_id (number)
comment_title (text)
score (number)
time_score (number)
final_score (number) 
created_time (timestamp)

Score is and integer that’s usually updated using $inc 1 or -1 whenever someone votes up or down for that record.
but time_score is updated using a function relative to timestamp and current time and other factors like how many (whole days passed) and how many (whole weeks passed) …..etc

So I do $inc and $dec on db directly but for the time_score, I retrieve data from db calculate the new score and write it back. What I’m worried about is that in case many users incremented the “score” field during my calculation of time_score then when I wrote time_score to db it’ll corrupt the last value of score.

To be more clear does updating specific fields in a record in Mongo rewrites the whole record or only the updated fields ? (Assume that all these fields are indexed).

  • 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-14T17:41:05+00:00Added an answer on June 14, 2026 at 5:41 pm

    By default, whole documents are rewritten. To specify the fields that are changed without modifying anything else, use the $set operator.

    Edit: The comments on this answer are correct – any of the update modifiers will cause only relevant fields to be rewritten rather than the whole document. By “default”, I meant a case where no special modifiers are used (a vanilla document is provided).

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

Sidebar

Related Questions

I have a MongoDB collection with data that was not saved through my Derby
Let's assume that I have a collection in mongodb, where all of its documents
I have a collection of articles in MongoDB that has the following structure: {
I have an applicaton written in PHP that retrieves files from mongoDB Grid collection,
I have a collection of data that looks as follows: id name c1 c2
MongoDB noob here... I have a collection as follows... > db.students.find({_id:22},{scores:[{type:'exam'}]}).pretty() { _id :
I have a MongoDB Collection called Questions which holds JSON Objects that look like
I have MongoDB.BsonDocument, i want to convert that BsonDocument to List of collection, how
I have a mongoDB collection with an array field that represents the lists the
Let's say you have a collection of documents that are structured as follows: {

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.