Rename a function

Creating and updating a function requires:

Problem

You need to change the name of a function within the current database.

Solution

Use the Update function:

Copied!
(
  ('create_post'),
  {
    body: (
      (
        ['title', 'body', 'author'],
        (
          ('posts'),
          {
            data: {
              title: ('title'),
              body: ('body'),
              author: ('author'),
            },
          }
        )
      )
    ),
  }
)
{
  ref: ("create_post"),
  ts: 1624310581310000,
  name: 'create_post',
  body: ((["title", "body", "author"], (("posts"), {data: {title: ("title"), body: ("body"), author: ("author")}})))
}
Query metrics:
  •    bytesIn:  268

  •   bytesOut:  362

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    1

  •  readBytes:  187

  • writeBytes:  346

  •  queryTime: 18ms

  •    retries:    0

Discussion

After a function has been renamed, any queries that attempt to call the function by its old name fail.

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!