IdentityManager
By default Mirage uses autoincrementing numbers starting with 1 as IDs for records. This can be customized by implementing one or more IdentityManagers for your application.
An IdentityManager is a class that's responsible for generating unique identifiers. You can define a custom identity manager for your entire application, as well as on a per-model basis.
A custom IdentityManager must implement these methods:
fetch, which must return an identifier not yet usedset, which is called with anidof a record being insert into Mirage's databasereset, which should reset database to initial state
Check out the advanced guide on Mocking UUIDs to see a complete example of a custom IdentityManager.
Methods
fetch(): String
Returns the next unique identifier.
reset(): any
Resets the identity manager, marking all unique identifiers as available.
set(uniqueIdentifier: String, Number): any
Registers uniqueIdentifier as used.
This method should throw is uniqueIdentifier has already been taken.