Diligence is still under development and incomplete, and some this documentation is wrong.
For a more comprehensive but experimental version download the Savory Framework,
which was the preview release of Diligence.
This straightforward service generates unique integers in a series, using MongoDB atomic operations. No number in a specific series will ever be generated again. This service is thus useful for generating integer IDs.
Note that uniqueness is only guaranteed by the intactness of the MongoDB database. If you somehow lose it and have to start over, there's a chance you would regenerate IDs that have already been used. If you need unique IDs that don't have this limitation, you'll want to use GUIDs instead.
Usage is very simple:
var id = Diligence.Serials.next('person')
Each series is stored as a single document in the "serials" MongoDB collection. By default, the method will create the series document if it does not yet exist, initializing it with the number 1.
The Diligence Manual is provided for you under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The complete manual is available for download as a PDF.