Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.25 KB

uuid.md

File metadata and controls

41 lines (30 loc) · 1.25 KB
layout api-command
language Java
permalink api/java/uuid/
command uuid
io
r
string

Command syntax

{% apibody %} r.uuid([string]) → string {% endapibody %}

Description

Return a UUID (universally unique identifier), a string that can be used as a unique ID. If a string is passed to uuid as an argument, the UUID will be deterministic, derived from the string's SHA-1 hash.

RethinkDB's UUIDs are standards-compliant. Without the optional argument, a version 4 random UUID will be generated; with that argument, a version 5 UUID will be generated, using a fixed namespace UUID of 91461c99-f89d-49d2-af96-d8e2e14e9b58. For more information, read Wikipedia's UUID article.

{% infobox %} Please take into consideration when you generating version 5 UUIDs can’t be considered guaranteed unique if they’re computing based on user data because they use SHA-1 algorithm. {% endinfobox %}

Example: Generate a UUID.

r.uuid().run(conn);
// returns "27961a0e-f4e8-4eb3-bf95-c5203e1d87b9"

Example: Generate a UUID based on a string.

r.uuid("[email protected]").run(conn);
// returns "90691cbc-b5ea-5826-ae98-951e30fc3b2d"