$collection = $this->_getCollection("counters");
$counter = $collection->findAndModify(
array(
"_id" => $name
),
array(
'$inc' => array(
"seq" => 1
)
)
);
return $counter["seq"];
What was returned?
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ was added later
The logic is
Investigate and deal with some table name in counters, such as seq of (aaa_aaa)
Seq of this table (aaa_aaa) is then stored in the id value in this table (aaa_aaa)
$inc
In mongo, it increases by 1, so the result increases by 1 each time.