newId()

Get a number that is unique across all databases.

Signature

newId(): String

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 should not be used to generate random numbers.

Parameters

None

Return value

Type Description

String

Numeric string value that is a unique number 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!