Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.14 KB

README.md

File metadata and controls

38 lines (25 loc) · 1.14 KB

Alternate Unique Identifier Library Module for eXist-db

ULID — Universally Unique Lexicographically Sortable Identifier

UUIDs are usually quite nice to use as random IDs. Most people including me would simply use a UUID v4 as a way to generate random IDs. But UUIDs v4 is just plain randomness. There is no way to tell if a uuid-a > uuid-b or the vice versa. That is when I discovered ULID. ULID stands for Universally unique Lexicographically sortable IDentifiers. ULID ensures that the IDs can be monotonically ordered and can be sorted even when generated within a millisecond. There are ²⁸⁰ possible ids within a millisecond.

xquery version "3.1";

import module namespace altid = "https://exist-db.org/xquery/altid";

altid:ulid()

From SecureRandom

This library function was inspired by the article at: Moving away from UUIDs by Neil Madden

Here is a sample XQuery

xquery version "3.1";

import module namespace altid = "https://exist-db.org/xquery/altid";

altid:secure-random()

It returned twRminDVuAMHoNTXwtHuV5wS2rs after one of the calls.