newId()

Get a unique string-encoded 64-bit integer.

Signature

newId() => ID

Description

The newId() method returns a number that is guaranteed to be unique across all databases and is suitable for constructing the document ID part of a document reference.

Document IDs are generated using the Twitter Snowflake algorithm. The IDs are based on time instead of sequential numbers and are generally increasing. The newId() method shouldn’t be used to generate random numbers.

Parameters

None

Return value

Type Description

ID

Numeric value that is unique across databases.

Examples

newId()
"374494810266927169"

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!