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.
Serials Service
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
Make sure to check out the API documentation for Diligence.Serials.
Usage is very simple:
document.executeOnce('/diligence/service/serials/') 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.