NewId

NewId()
NewId()
NewId()
NewId()
new_id()
new_id
NewId()
NewId()

Description

This NewId function produces a unique number. This number is guaranteed to be unique across the entire cluster and once generated is never generated a second time. This identifier is suitable for constructing the id part of a reference.

Parameters

None.

Returns

A unique number.

Examples

The query below returns a unique number.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "new_id": null }'
client.Query(NewId());
System.out.println(client.query(NewId()).get());
result, _ := client.Query(f.NewId())

fmt.Println(result)
client.query(NewId())
client.query(q.new_id())
$client.query do
  new_id
end
client.query(NewId())
client.query(q.NewId())
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": "181388643266462208" }
"181388643266462208"
"181388643266462208"
181388643266462208
"181388643266462208"
"181388643266462208"
"181388643266462208"
"181388643266462208"
181388643266462208

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!