Skip to content

Autoincrement Bundle for Doctrine ODM MongoDB based Symfony2 applications.

License

Notifications You must be signed in to change notification settings

Zimtronic/ZimAutoinc

Repository files navigation

ZimAutoinc

Autoincrement Bundle for Doctrine ODM MongoDB based Symfony2 applications.

Trying to get auto increment values that are not primary keys is not a simple task using Doctrie ODM with MongoDB. This very simple bundle will help with that objective.

Autogenerated integer values are not efficient in distributed horizontal scalable databases like MongoDB so I advice not to use this values for primary keys if itended for sharded deploys.

Configuration

Add following entries to config.yml


zim.autoincrement:
                    collection: counters
                    counters: ['myid']

Add as many id counters as needed on counters config value.

Usage

The bundle will add 'zim.autoincrement.generator' service to the container. To generate a new value just call service "generator" method passing the target counter name as argument.

For example inside a controller class:


$next_available_value = $this->get('zim.autoincrement.generator')->generate('myid');

About

Autoincrement Bundle for Doctrine ODM MongoDB based Symfony2 applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages