Identity

Identity()
Identity()
Identity()
Identity()
identity()
Identity()

Description

The Identity function returns the ref of the document associated with the authentication token used for the request. If a document does not exist, an error is returned.

Parameters

None.

Returns

A reference type to the identity associated with the current client authentication token.

Examples

// Not available in this language yet.
{
  "errors": [
    {
      "position": [  ],
      "code": "missing identity",
      "description": "Authentication does not contain an identity"
    }
  ]
}
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "identity": null }'
HTTP/1.1 400 Bad Request
{
  "errors": [
    {
      "position": [  ],
      "code": "missing identity",
      "description": "Authentication does not contain an identity"
    }
  ]
}
result, _ := client.Query(f.Identity())

fmt.Println(result)
{181388642114077184 0xc4202d09e0 <nil>}
System.out.println(client.query(Get(Identity())).get());
{
  ref: (id = "200118070142829056", collection = ref(id = "users", collection = ref(id = "collections"))),
  ts: 1527106313732119,
  data: {email: "alice@example.com"}
}
client.query(q.Identity())
.then((ret) => console.log(ret))
Ref(id=181388642114077184, collection=Ref(id=characters, collection=Ref(id=collections)))
# Not available in this language yet.
{
  "errors": [
    {
      "position": [  ],
      "code": "missing identity",
      "description": "Authentication does not contain an identity"
    }
  ]
}
// Not available in this language yet.
{
  "errors": [
    {
      "position": [  ],
      "code": "missing identity",
      "description": "Authentication does not contain an identity"
    }
  ]
}

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!