Function metadata

Creating and updating a function requires:

Problem

You need to store additional metadata within the function document.

Solution

Set the data field in a function:

Copied!
adminClient.query(
  q.(
    q.('create_post'),
    { data: { env: 'test' } }
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  ref: ("create_post"),
  ts: 1635293426560000,
  name: 'create_post',
  body: ((["title", "body", "author"], (("posts"), {"data": {"title": ("title"), "body": ("body"), "author": ("author")}}))),
  data: { env: 'test' }
}
Query metrics:
  •    bytesIn:   92

  •   bytesOut:  384

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    1

  •  readBytes:  513

  • writeBytes:  246

  •  queryTime: 26ms

  •    retries:    0

Discussion

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

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!