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!
client.query(
  q.(
    q.('create_post'),
    {
      body: q.(
        q.(
          ['title', 'body', 'author'],
          q.(
            q.('posts'),
            {
              data: {
                title: q.('title'),
                body: q.('body'),
                author: q.('author'),
              },
            }
          )
        )
      ),
    }
  )
)
.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: 1622572664750000,
  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!