{"repo":"mhayes853/swift-uuidv7","free":true,"listed":false,"github":"https://github.com/mhayes853/swift-uuidv7","clone":"git clone https://github.com/mhayes853/swift-uuidv7.git","description":"RFC 9562 compliant UUID v7 type in Swift with integrations for popular libraries.","language":"Swift","stars":35,"topics":["appintents","database","persistence","random","randomness","swift","uuid","uuid-generator","uuidv7"],"license":"MIT","category":"databases-storage","readme_excerpt":"Swift UUIDV7 An RFC 9562 compliant UUIDV7 data type with cross-platform support and support for popular libraries. Overview Swift’s UUID type in Foundation represents any kind of UUID, but most commonly it is used as a version 4 UUID. Version 4 UUIDs are generated entirely based on random data which is fine, but runs into an ordinality problem as a result of the data being entirely random. For instance, how do you sort a collection by a UUID? Is that even a reasonable thing to do? UUIDV7 on the other hand, embeds a timestamp in its most significant 48 bits which enables ordinality across ids. Therefore, you can sort a collection by referring to a UUIDV7 as a sort key. One of the most common use cases for such a need is as a primary key in databases. UUIDs make great primary keys because of their randomness, but the complete randomness of v4 UUIDs are poor for index locality. Since UUIDV7 uses a timestamp alongside random data, it has better index locality whilst still maintaining similar levels of randomness to v4 UUIDs. Why a separate type? UUIDV7 holds a few extra properties that cannot be guaranteed in a typical Foundation UUID, most notably the timestamp and the notion of ordinality. On the timestamp, one could easily make an extension property on a Foundation UUID that interprets the first 48-bits as a timestamp, but this comes as the expense of the caller needing to be aware that such a property only holds true for UUID versions that use a timestamp in the first place. ","default_branch":null,"files":null,"tree":[],"storefront":"/r/mhayes853","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mhayes853/swift-uuidv7/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}