Backend logic?

Hello,

I’m new to fauna. One of the major selling points for me was the ability to go serverless and run the business logic on fauna (if I understood this correctly!), even when it involves calling other services and RESTful APIs. However, I have not been able to find how to do this.

As a simple example, I was to send an email, let’s say for forgotten passwords, where I have to use a service like sendgrid for that. How and where can I call sendgrid from fauna to send an email? Where should I put this code? I didn’t find anything in Functions to send a RESTful API request.

It would be great if someone could point me to the right direction for this.

Fauna does provide user-defined functions, where you can use any FQL functions to perform whatever business logic you need.

However, FQL queries can only access document data stored in the database, and only limited contextual information, such as the time of day. It is not possible to call external APIs or serverless functions, nor to perform tasks such as sending email, from an FQL query.

To achieve your goal, your application logic would need to send emails, or connect to APIs.

1 Like

Thank you @ewan. I must have misunderstood then. I watched Rob Sutter’s session on Learn With Jason, and I thought he specifically talked about this.

I wonder what “serverless” means though, if I need to run a server just to reset the user’s password. Again, I must have misunderstood.

Thank you for your prompt clarification. I appreciate it.

“Serverless” does not mean that there is no server involved, it means that someone else runs and maintains the server that you need for your application, functions, or content.

Have a look at AWS Lambda – Serverless Compute - Amazon Web Services or Netlify Functions to get a better understanding of how you can make your application logic execute “in the cloud”.

1 Like

Thank you @ewan for your answers