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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:11:18+00:00 2026-05-27T15:11:18+00:00

$coll->update( array( uid=(int)$uid, status=>1, time=>array(‘$gt’=>0,’$lte’=>$time) ), array( ‘$set’=>array(status=>0) ) ); If you can’t read

  • 0
$coll->update(
  array(
    "uid"=(int)$uid,
    "status"=>1,
    "time"=>array('$gt'=>0,'$lte'=>$time)
  ),
  array(
    '$set'=>array("status"=>0)
  )
);

If you can’t read PHP, CLI version of above code:

db.we.update({"uid":1,"status":1,"time":{"$lte":1324403899}},{"$set":{status:0}})

where time is a timestamp integer, and status is int 0 or 1.

  • 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-27T15:11:19+00:00Added an answer on May 27, 2026 at 3:11 pm

    This is the MongoDB default behaviour for updates. If you want to update multiple documents at once, you’ll explicitly have to provide the multi flag:

    db.collection.update( criteria, objNew, upsert, multi )
    

    so you’d have to use

    db.we.update({"uid":1, "status":1, "time" : {"$lte":1324403899}},
                 {"$set":{status:0}}, 
                 false, 
                 true);
    

    instead.

    From the documentation:

    If you are coming from SQL, be aware that by default, update() only modifies the first matched object. If you want to modify all matched objects, you need to use the multi flag.

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

Sidebar

Related Questions

Coll.update(condition, new BasicDBObject($set, data), true, true)) This is my update query in mongodb for
I'm having a tough time understanding laziness. Can someone help me understand why my
public class Foo { public void DoFoo() { int x; var coll = TheFunc(bar,
Of these two options: var result = from c in coll where c %
A friend gave me this code snippet in Clojure (defn sum [coll acc] (if
Suppose I create collection like Collection<IMyType> coll; Then I have many implelentations of IMyTypem
<li> <h4 class=title-exp-coll title-expand> <span class=exp-coll></span>Bookmarks</h4> <div class=item-list> <ul> <li class=first><div>first Asset</div></li> <li><div>Latest Updates</div></li>
EDIT : Added UL class <ul class=expand-coll-list> <li> <h4 class=title-exp-coll title-expand> <span class=exp-coll></span>Bookmarks</h4> <div
------------------------- clojure.core/seq ([coll]) Returns a seq on the collection. If the collection is empty,
conj is used in (conj coll item), for example (conj #{} Stu). But, I

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.