Create a function
Creating and updating a function requires:
|
Solution
Use the CreateFunction
function:
Let’s create a function to allow authors to create new blog posts. We’ll set it up to allow the author to provide a title and body. This way authors are constrained by what data they can store on a post document.
{
ref: Function("create_post"),
ts: 1622572663690000,
name: 'create_post',
body: Query(Lambda(["title", "body"], Create(Collection("posts"), {"data": {"title": Var("title"), "body": Var("body")}})))
}
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!