Fauna in frontend or backend

I’m king of lost about where to trigger fauna. I’ve read that you can make direct queries to faunadb in frontend (but for that we need to authenticate with fauna and use UDFs and TWOs), in the other side if we want we can use fauna to make queries in the backend (so it will consume my servers resources and for that uses TROs and TWOs – please note that I only need simple queries and not paginate,etc). Am I right in this first question?

And last question, what is the difference between a TRO and a UDF, because I see in the example that a UDF is Paginate(Match(“users_by_email”, “abc@fauna”)] , so if I need just a query to Match a column to get back data, that will count just as a TRO, or both TRO and UDF?

Hi Lester,

Thanks for your interest in Fauna. I’ll do my best to answer your questions for you.

First, the difference between UDFs and TWO/TROs. A UDF is a User Defined Function; it’s a function you create in the database, similar to stored procedures in other databases, which you can call via the Fauna API just as you would any built-in function. TWO/TROs are Transactional Write Operations and Transactional Read Operations, respectively. They are not part of the database, per se, but are rather ways we measure your use of the database. They, along with Transactional Compute Operations and Storage, are the primary metrics by which you will be charged for your use of the database. UDFs consume TCOs, primarily.

Because Fauna is a database you wouldn’t trigger it so much as make use of it, just like any other database. Whether your queries are being generated in the frontend of your application or the backend, it doesn’t matter to Fauna. In either case, your application will connect to Fauna, run a series of function and API calls to query for data, and Fauna will respond with the results of those queries. Calls to Fauna consume resources on the Fauna database; Fauna does not make external calls to other services so it would not consume any resources on your server by itself (though subsequent actions in your application may, depending on what you do with the results of your queries).

Please let me know if you have any follow up questions on these items or if we should mark this question as answered.

Thanks,
Cory