Rank 1: Thread
I understand we need to add the event to appwrite.json. But even after specifying it in json can't add event
Votes
0
Replies
23
Participants
Unknown
Messages
24
Rank 1: Thread
I understand we need to add the event to appwrite.json. But even after specifying it in json can't add event
Rank 1: Thread
{
"projectId": "hidden",
"projectName": "hidden",
"events": [
"databases.*.collections.chat.documents.create"
]
}
This is how my appwrite.json looks currently
Admin
can't add event
What do you mean?
Rank 1: Thread
@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
Admin
Events disappear after refreshing page
Admin
Did you click on update after adding the event?
Admin
You definitely should put it in your appwrite.json, but that's the wrong place to put it. It should go under your function
Rank 1: Thread
I see, can you guide me to where I can find an example appwrite.json file specific to this
Admin
Did you initialize your function with appwrite init function?
Rank 1: Thread
No, I created it directly in cloud and then deploy using appwrite cli
Admin
Here are the docs: https://appwrite.io/docs/command-line-deployment
Rank 1: Thread
Thanks @Steven ✨
Rank 1: Thread
@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
Rank 1: Thread
But everytime the event is sent as empty to the cloud by cli
Rank 1: Thread
{
"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
Rank 1: Thread
I found out the issue
Rank 1: Thread
We need to hit update, even after clicking on create in events
Rank 1: Thread
Without update it just vanishes
Rank 1: Thread
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
Admin
how did you "update the function"
Rank 1: Thread
I updated from cloud console of appwrite (By clicking add event button)
Admin
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
Rank 1: Thread
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
Admin
[SOLVED] Events disappear after refreshing page