Nim OID support. An OID is a global ID that consists of a timestamp, a unique counter and a random value. This combination should suffice to produce a globally distributed unique ID. This implementation was extracted from the MongoDB interface and is thus binary compatible with a MongoDB OID.
This implementation calls initRand() for the first call of genOid.
Procs
proc `==`(oid1: Oid; oid2: Oid): bool {.inline, ...raises: [], tags: [].}
- Compares two OIDs for equality. Source Edit
proc generatedTime(oid: Oid): Time {....raises: [], tags: [].}
- Returns the generated timestamp of the OID. Source Edit
proc genOid(): Oid {....raises: [], tags: [TimeEffect].}
-
Generates a new OID.
Example:
doAssert ($genOid()).len == 24
Example: cmd: -r:off
echo $genOid() # for example, "5fc7f546ddbbc84800006aaf"
Source Edit