I
I
Igor Tkachenko2016-07-31 19:41:20
PHP
Igor Tkachenko, 2016-07-31 19:41:20

Is there adequate support for auto increment values ​​in mongodb?

Yuzal such a thing:

$ret = static::findAndModify(['_id' => $name], ['$inc' => ['seq' => 1]], ['new' => true, 'upsert' => true]);
      if(!isset($ret->seq))
      {
        return 1;
      }
      return ++$ret->seq;

but this is too much, is there something adequate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-07-31
@Nc_Soft

RTFM
https://docs.mongodb.com/v3.0/tutorial/create-an-a...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question