search

Home  >  Q&A  >  body text

mongodb有个地方看不懂

$collection = $this->_getCollection("counters");

$counter = $collection->findAndModify(
        array(
            "_id" => $name
        ),
        array(
            '$inc' => array(
                "seq" => 1
            )
        )
    );
    
    return $counter["seq"];
    
    
    

返回的是什么?
__________________________________________后来补充______________________________________________

逻辑是
在counters中查处某个的表名例如(aaa_aaa)的seq
然后将这个表(aaa_aaa)的seq存入该表(aaa_aaa)中的id值

淡淡烟草味淡淡烟草味2797 days ago567

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-27 09:04:26

    $inc In mongo, it increases by 1, so the result increases by 1 every time

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-27 09:04:26

    Seq+1 of the document whose "_id" attribute is $name in the counters collection

    reply
    0
  • Cancelreply