Back

how do I trigger a server function if any document in table changed?

  • 0
  • Functions
sophex89
9 Jan, 2024, 16:02

I want to trigger a function every time there is any change in the db how do I do that?

for example lets say I have a blog and a user commented, I want to trigger a server function

TL;DR
To trigger a server function whenever there is any change in the database, you can use events in Appwrite. First, deploy your function, then go to the Appwrite console, navigate to your function, and go to the settings section. Under events, you can define the event you want to trigger your function. For example, if you want to trigger the function when a new document is created in the users collection, you can define that from the function settings in the console. You can learn more about events in the documentation here: [link to docs].
kamal.panara
9 Jan, 2024, 16:09

you can trigger it by defining it from function settings from console

kamal.panara
9 Jan, 2024, 16:11

for example here I'm triggering one of my cloud function when new document is created in users collection

kamal.panara
9 Jan, 2024, 16:13

you can define the event in function settings. first of all deploy your function then goto appwrite console >functions >your-function > settings then find Events. and add event.

kamal.panara
9 Jan, 2024, 16:13

you can learn more about events here: https://appwrite.io/docs/advanced/platform/events

sophex89
9 Jan, 2024, 16:14

got it, it is such a small section in the documentation for important feature

sophex89
9 Jan, 2024, 16:14

thanks!

D5
9 Jan, 2024, 16:24

@sophex89 Can I mark this as solved?

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