ReQL command: uuid

Command syntax

r.uuid([string]) → string

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.

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.

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"

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/java/uuid/