-1

I'm using in my project mandago ODM for mongodb.

http://mandango.org

I know that in MongoDb you can define JS functions on fields but I don't know how to do it with mandango. I create autoincrement ID field in more clever way than getting last record then incrementing it in PHP and saving in db. So my question is how to create an autoincrement field in mandago ODM?

I'd put some code but there's really nothing to put just pure code classes generated by Mondator.

Community
  • 1
  • 1
Robert
  • 19,800
  • 5
  • 55
  • 85

1 Answers1

1

After some research I have found out how to solve problem.

You need to add in your model mapping file 'idGenerator' => 'sequence'

in my case it looks as following:

$modelMapping = array(
    'Model\User' => array(
        'isEmbedded'    => false,
        'idGenerator'   => 'sequence',
        ...

It will autoincrement _ID key in your document.

Robert
  • 19,800
  • 5
  • 55
  • 85