Back

[Solved] Should I use a function or write client code?

  • 0
  • Databases
  • Web
zwarag\\harrys
25 Apr, 2023, 06:45

I implemented a simple feature where a user can track how much money he saved by taking a bus instead of driving with car. Currently, each time he drives with the bus, an amount is added to his savings. However there is no history of how that came to be. I would like to add this history.

My question is, should do a second request on the client side be done to add an entry into the history document? Or should I write an appwrite function that reacts to updates on the savings document and adds an entry to the history document?

TL;DR
It's better to use a function to add an entry to the history document. Functions with Server level API offer more possibilities as the options grow. Think of functions as microservices that compose the backend.
Binyamin
25 Apr, 2023, 12:54

Either ways can work, but it's better to do it in a function as when the option will grow you'll be able to achieve much more using function with Server level API rather then the Client level API.

A good rule of thumb is to think of functions as microservices that together are composing the backend for you.

zwarag\\harrys
25 Apr, 2023, 15:19

Cool thx @Binyamin ✌️

zwarag\\harrys
28 Apr, 2023, 21:01

[Solved] Should I use a function or write client code?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more