$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.
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:
so you’d have to use
instead.
From the documentation: