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
- Got message for auto payment of 15usd fo...
how did this happen? 1. i claimed my 50usd credits via jsm hackathon - https://hackathon.jsmastery.pro/ 2. it asked me which org. to apply the credits on, i se...
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...