Key metadata

Reading or writing key definitions requires an admin key.

Problem

You need to store additional metadata within a key document.

Solution

Set the data field in a key:

Copied!
adminClient.query(
  q.(
    q.(q.(), '1'),
    {
      data: {
        team: 'Engineering',
      },
    },
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  ref: ((), "1"),
  ts: 1631728043380000,
  role: 'admin',
  hashed_secret: '$2a$05$kdsBSqgV/EoShNny0aoCMuccN94tHSqJOuTTbJ58SRIrHixS/MUhm',
  data: { team: 'Engineering' }
}
Query metrics:
  •    bytesIn:   104

  •   bytesOut:   222

  • computeOps:     1

  •    readOps:     0

  •   writeOps:     1

  •  readBytes:   128

  • writeBytes:   222

  •  queryTime: 368ms

  •    retries:     0

Discussion

You can add the metadata while creating or updating a key 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!