I understand we need to add the event to appwrite.json. But even after specifying it in json can't add event
{
"projectId": "hidden",
"projectName": "hidden",
"events": [
"databases.*.collections.chat.documents.create"
]
}
This is how my appwrite.json looks currently
can't add event What do you mean?
@Steven I am trying to add an event that will automatically trigger a function when any document inside the chat collection will be created. But as soon as I go to the appwrite cloud and try to create the event through the create event button and put in all details it is added but disappears on refresh
Events disappear after refreshing page
Did you click on update after adding the event?
You definitely should put it in your appwrite.json, but that's the wrong place to put it. It should go under your function
I see, can you guide me to where I can find an example appwrite.json file specific to this
Did you initialize your function with appwrite init function?
No, I created it directly in cloud and then deploy using appwrite cli
Here are the docs: https://appwrite.io/docs/command-line-deployment
Thanks @Steven ✨
@Steven I tried putting events under functions but still not working. I even tried creating function using appwrite init function and then adding an event and then updating the function
But everytime the event is sent as empty to the cloud by cli
{
"projectId": "hidden",
"projectName": "hidden",
"functions": [
{
"$id": "hidden",
"name": "createChatCollection",
"runtime": "dart-2.17",
"path": "functions/createChatCollection",
"entrypoint": "lib/main.dart",
"ignore": [
".packages",
".dart_tool"
],
"execute": [],
"events": [ "databases.*.collections.chat.documents.*.create"
],
"schedule": "",
"timeout": 15
}
]
}
This is how my appwrite.json looks currently
I found out the issue
We need to hit update, even after clicking on create in events
Without update it just vanishes
Create event already has create button, so shouldn't create add the event instead of having to click on two buttons. I think it's a bit confusing for new comers
how did you "update the function"
I updated from cloud console of appwrite (By clicking add event button)
if you update in the console, your appwrite.json will be out of sync. i highly recommend updating in your appwrite.json and then deploy with appwrite deploy function
No I understand that, I wanted to say that to update in console we are having to click on three buttons. "+ Add Event" -> "Create" -> "Update". I think if we didn't need to click on the last update button it would have been better from a UX point of view
[SOLVED] Events disappear after refreshing page
Recommended threads
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- router_deployment_not_found
I updated my function a few times and now i am getting the error: router_deployment_not_found I even reverted back to my original code but i am still getting th...
- Cloud function deploy stucks in processi...
Been trying for the last hours to deploy my function but for whatever reason, alwasy stuck on processing!