Token metadata

Problem

Store additional metadata within a token document.

Solution

Set the data field in a token:

Copied!
client.query(
  q.(
    q.(q.(), '1'),
    {
      data: {
        team: 'Marketing',
      },
    },
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  ref: ((), "1"),
  ts: 1631739422930000,
  instance: (("users"), "1"),
  data: { team: 'Marketing' }
}
Query metrics:
  •    bytesIn:  104

  •   bytesOut:  239

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    1

  •  readBytes:  138

  • writeBytes:  177

  •  queryTime: 26ms

  •    retries:    0

Discussion

You can add the metadata while creating or updating a token document.

More information

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!